On Thu, 18 Apr 2002 17:35:17 +0000 (UTC), Florent Guillaume
<[EMAIL PROTECTED]> wrote:

>I'll investigate clearing the _v_ caches at the end of the transaction,
>using the REQUEST._hold hack mentionned earlier.

Below is the class I use for this. Just call
attribute_cleaner(self,'_v_my_attribute') before assigning to
_v_my_attribute, and it will be cleared at the end of the ZODB
transaction.

I wonder if this is generally useful enough to go in the ZODB
distribution?



class attribute_cleaner:
    def __init__(self,client,attr):
        self.client = client
        self.attr = attr
        get_transaction().register(self)

    def ClearCache(self,*args):
        try:
            delattr(self.client, self.attr)
        except AttributeError:
            pass
        except KeyError:
            pass

    tpc_finish = tpc_abort = abort = abort_sub = ClearCache

    def tpc_begin(self,transaction,subtransaction=None): pass
    def commit(self,object,transaction): pass
    def tpc_vote(self,transaction):      pass
    def commit_sub(self,transaction):    pass




Toby Dickenson
[EMAIL PROTECTED]


_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to