Comment 4 for bug 586526

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

> Why do you want to override _p_invalidate?

I wanted a persistent object that, dependent on its own state may be unghostifiable. A _p_immortal flag that is saved as part of the object state would be good enough.

Based on the documentation, I thought something like this would work.

  class P(persistent.Persistent):

    def __init__(self, immortal=False):
      self._immortal = immortal

    def _p_invalidate(self):
      immortal = self._immortal
      super(P, self)._p_invalidate()
      if immortal:
        self._p_activate()

But it doesn't, due to the problem I reported.

The reason I want this is to be able to maintain a memory-only structure along with my persistent object. It may be expensive to recreate from scratch, but can be updated cheaply if done often enough (like once every time we are told of changes to the persistent object). The immortal flag would be used only when the structure *would* be expensive to recreate. (As determined either by some formula or by a human operator).