AppConfig in JSON returns unicode

15 views
Skip to first unread message

Joe Barnhart

unread,
Apr 17, 2018, 7:43:02 PM4/17/18
to web2py-users
This is sort of a bug, sort of a feature.  I just converted to the JSON version of AppConfig (in the gluon/contrib) and discovered the strings it produces are all unicode -- even in Python 2.x environments.

I'm not sure of ALL of the ramifications, but I discovered it causes crypt fields to fail when a key is provided.  I'm using a known key because I need to keep compatibility with past users who have accounts, but as soon as I tried to use the crypt field to enter the first logon when initializing the new website, it failed. It tested the "digest_alg" to see if it was a "str" and failed because it was "unicode".

Anyway, the workaround is to use "str()" on any fields that are critical.  Longer term, it may be useful for the maintainer of AppConfig to return strings instead of unicode from JSON format files.

-- Joe

Reply all
Reply to author
Forward
0 new messages