[Zope-dev] ZPatterns feature patch: kickTriggers

Steve Alexander steve@cat-box.net
Fri, 23 Feb 2001 09:55:58 +0000


I've patched DataSkins.py to add this method:


     def kickTriggers(self,_v_status_=_v_status_,_v_dm_=_v_dm_):
         """Cause triggers to be set off at the end of this
            transaction, without needing to set any attributes."""
         self = self._canonicalForm()
         if self._v_status_ is not ChangedStatus:
             d=self.__dict__
             d[_v_dm_]._objectChanging(self)
             d[_v_status_] = ChangedStatus


I often want triggers to fire on a DataSkin because some other 
specialist knows about a change that will affect that Dataskin's 
computed attributes. I don't need to change the DataSkin; I just want 
the triggers to fire at the end of the transaction.

My current hack for causing triggers to fire without needing to actually 
change an attribute has recently stopped working.

   object.propertysheets.Basic.
           manage_changeProperties(bogus_property_to_prime_triggers=1)

This is due to recent optimisations in OFS/PropertySheets.py in Zope 2.3 
from CVS -- now, an object only gets changed when you alter a property 
that actually exists. This is a good thing, as it reduces bloat in the ZODB.

I'd welcome suggestions on a better name for the method than 
"kickTriggers". :-)

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net