Comment 4 for bug 185066

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

Your change fixes the immediate problem, but I am a bit concerned that custom _p_deactivate and (with the fix) _p_invalidate methods are called on objects marked UPTODATE, but whose state hasn't been loaded. What that means is that any nontrivial custom _p_deactivate/_p_invalidate needs to check whether the state is valid (is there even a reliable way to test that?).

To illustrate:

  class Foo(persistent.Persistent):
    bar = 0
    def __init__(self):
      self.bar = 1
    def _p_deactivate(self):
      assert self.bar

Will fail the assertion when the object is loaded.

Bypassing the custom _p_deactivate as I suggested solves this problem (I think).