views:

377

answers:

3

I'm looking for a way to serialize generic Python objects between a CherryPy-based server and a Python client running on a Symbian phone.. Since pyS60 doesn't implement the pickle module, how would you do it?

I know about Cerealizer but it requires you to register classes before use (which I'd like to avoid) and doesn't look very mature.. So, what would you use? Python 2.2's pickle module maybe, extracted from the sources? XML, JSON? Which one of the several libraries? :)

+2  A: 

What's wrong with using the pickle module?

fivebells
pickle 2.2, you mean? Nothing, I guess.. Just asking for an opinion :)
Joril
+1  A: 

There is a json module someone wrote for PyS60. I'd simply grab that, serialize things into json and use that as the transfer method between the web/client app.

For the json lib and a decent book on PyS60: http://www.mobilepythonbook.org/

Rick
I have that book right here, but completely missed the JSON part X-) Thanks!
Joril
+1  A: 

The last versions of Python (>1.9) have the module pickle and cPickle are available

Another alternative to JSON serialization is to use the netstring (look on wikipedia) format to serialize. It's actually more effective than JSON for binary objects.

You can find a good netstring module here http://github.com/tuulos/aino/blob/d78c92985ff1d701ddf99c3445b97f452d4f7fe2/wp/node/netstring.py (or aino/wp/node/netstring.py)

Agathe
Looks like netstring is designed just for strings, not for generic objects.. Thanks for your tip though :)
Joril
you're right. It's very handy for dict objects whose values are all strings
Agathe