> Where is what stored? Are the fields in the DB prefixed with a u?
** model.py
class Profile(DeclarativeBase):
...
profile_data = Column(UnicodeText)
** postgres
CREATE TABLE profile
(
...
profile_data text
)
SAMPLE RECORD (as is):
{u'tempCounter': 1, u'profile_name': u'DefaultProfile', u'containers':
[{u'tempCounter': 1, u'desktops': [{u'tempCounter': 0, u'panels':
[]}]}]}
** controller
@expose('json')
def load_profile(self,id):
db_profile = DBSession.query(Profile.profile_data) ...
pprint.pprint(db_profile.profile_data)
pprint.pprint OUTPUT FOR SAMPLE RECORD:
u"{u'tempCounter': 1, u'profile_name': u'DefaultProfile',
u'containers': [{u'tempCounter': 1, u'desktops': [{u'tempCounter': 0,
u'panels': []}]}]}"
It seems that at store time the string is not being treated correctly
as unicode, and stored like a normal string with u everywhere ...
isn't it?
>From now on, I can return dict(db_profile.profile_data) to my
javascript application ...
This is how I populate the database (another controller metod)
new_profile = Profile()
DBSession.add(new_profile)
new_profile.user = query.user_id
new_profile.profile_name = item[u'profile_name']
new_profile.profile_data = item
Where item is the same JSON string as above, but without the u' ...
Maybe I can strip them out with a string replace or regexp
substitution ... but still I'm garbled up on this :(
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---