2007-03-08

How to debug UnpickleableError

Sometimes happens that you put a security proxied object into a persistent object's property. Then on transaction commit you get the error:
UnpickleableError: Cannot pickle objects
Now you can search al your code and guess where you set that property.
That can be solved much simpler:
modify ZODB/serialize.py temporarly as follows:
def _dump(self, classmeta, state):
# To reuse the existing cStringIO object, we must reset
# the file position to 0 and truncate the file after the
# new pickle is written.
self._file.seek(0)
self._p.clear_memo()
self._p.dump(classmeta)
try:
self._p.dump(state)
except:
#your favorite debugger's break command

self._file.truncate()
return self._file.getvalue()

And voila, classmeta is the class concerned, state is a dict holding the state. From these values it's piece of cake.

1 comment:

Unknown said...

Casinos in Malta - Filmfile Europe
Find deccasino the best Casinos in Malta including bonuses, games, games and the history of games. We https://febcasino.com/review/merit-casino/ cover all the worrione main reasons ventureberg.com/ to visit Casinos 토토 사이트 in