Comment 2 for bug 185066

Revision history for this message
Jacob Holm (jacobholm) wrote :

AFAICT the bug is still there in the trunk (I haven't checked the 3.8 branch), but I may have been unclear about what is actually happening... I'll try again.

The actual call to _p_deactivate happens in persistent/cPersistence.c:903-906, but is caused by the assignment "obj._p_changed = None" in ZODB/serialize.py:519.

The problem is that instances of a class like

  class Foo(persistent.Persistent):
    def _p_deactivate(self): pass

will stay in the UPTODATE state in spite of the "obj._p_changed = None" call. That again means the state of such an object will never be loaded from the database.

A possible fix would be to replace the line in ZODB/serialize.py with

  Persistent._p_deactivate(obj)

This would ensure that the object is properly loaded before the custom _p_deactivate has a chance to screw things up...