[ZODB-Dev] TypeError: ('object.__new__(SyncedLanguages) is not safe, use Persistence.Persistent.__new__()', ...

Godefroid Chapelle gotcha at bubblenet.be
Thu Dec 30 20:02:36 EST 2010


Hi,

I have been fighting all day to understand a bug with the unregistration 
of a utility from a local site.

After unregistration, some instance is left in the _subscribers list of 
the utilities AdapterRegistry in my local site.

This avoids me to remove the code as it does leave a broken object.

I have come to the conclusion that the code that first registered the 
utility is the culprit : the utility itself is not persistent.

It seems that the utility instance is unserialized at least two times 
during unregistration, which leads (if I understand well) to two 
different objects in memory.

This breaks the unsubscription algorithm that is based on object identity.

I naively tried to introduce the Persistent base class into the utility 
calss. When I try to access the utility instance again, I get the error 
mentioned in the subject of this mail :

TypeError: ('object.__new__(SyncedLanguages) is not safe, use 
Persistence.Persistent.__new__()', <function _reconstructor at 
0x1004297d0>, (<class 
'Products.LinguaPlone.vocabulary.SyncedLanguages'>, <type 'object'>, None))

If I understand well, the a posteriori introduction of Persistent cannot 
happen alone.

Can anyone tell me what I should do add to the class I try to make it 
actually persistent ?

PS: It is late here, I hope I have not told too many silly things
-- 
Godefroid Chapelle (aka __gotcha) http://bubblenet.be



More information about the ZODB-Dev mailing list