Add "dict" to SERIALIZABLE_TYPES in Row object's as_dict method

62 views
Skip to first unread message

Omri Har-Shemesh

unread,
Jul 27, 2012, 7:30:54 AM7/27/12
to web...@googlegroups.com
I recently defined a pickled SQLCustomType field for automatic dumping/loading of inserted types to the field.
The definition is:

pickled = SQLCustomType(
   type
= 'text',
   
native = 'text',
   encoder
= (lambda x: pickle.dumps(x)),
   decoder
= (lambda x: pickle.loads(x))
)

I use it to store a dictionary of values, which I later retrieve and send to the client via an jsonrpc service. For this
to work, I need to call the as_dict() method of the Row object I obtained from the database.
The problem is that "dict" is not recognized as a serializable by the as_dict method.
Is it safe to simply add it to the list of values already defined there? Is there a different way of letting the Row object
know how to decode the value? Is there a way to do it so that next time when I update web2py it will stay defined?

Thanks!
Omri

Massimo Di Pierro

unread,
Jul 27, 2012, 10:33:34 AM7/27/12
to web...@googlegroups.com
Send me a patch and I will take a look. It is probably safe.

Omri Har-Shemesh

unread,
Jul 30, 2012, 6:10:13 AM7/30/12
to web...@googlegroups.com
It seems to have been already done by Anthony, thanks for the quick fix!

:)

Omri
Reply all
Reply to author
Forward
0 new messages