Personally I think one should stay the hell away from transactions. They're not for you to fiddle with. I understand your question and even though I think it's a bit crazy I can see a benefit (simplicity for the programmer).
How about a trickery solution like this: class CatalogPathAware: def index_object(self, *a, **k): print self.__class__.__name__, "in for indexing!" class _MyProduct(CatalogPathAware): def __init__(self, id, title=''): self.id = id self.title = title def setTitle(self, title): # could be much more complicated self.title = title class MyProduct(_MyProduct): def setTitle(self, title): _MyProduct.setTitle(self, title) self.index_object() inst = MyProduct("instanceA") inst.setTitle('Peter') print inst.title You would basically rename your existing class from "Whatever" to "_Whatever" and continue as before. This does mean however that you have to explicitly write a function for each setter. On 6/17/05, Jürgen Herrmann <[EMAIL PROTECTED]> wrote: > > [ Jonathan wrote:] > > > > ----- Original Message ----- > > From: "Jürgen Herrmann" <[EMAIL PROTECTED]> > >> i make heavy use of indexes in my extension classes. these all inherit > >> from catalogpathaware, so i have to call object.reindex_object() on > >> each changed instance. calling it from attribute getters/setters f.ex. > >> is not a good idea, because changing 3 attributes will reindex the > >> object > >> 3 times. > >> > >> what i'd like to have is that such objects are reindexed automatically > >> before comitting a transaction. > > > > You can't index before committing. I think you need a different strategy: > > how about creating all of the new objects and then call the > > catalog/indexing > > mechanism. We do this for one of our large volume catalogs (1m+ records), > > by having an object class/catalog that are not 'aware' and then manually > > (well, thru a python routine) cataloging/indexing the objects. > > hmm, it's not about newly created objects. i want to have automatic > REindexing, in cleartext - i want to make it easy for the programmer: > he/she should just call an attribute setter or maybe change a relation > and just before the transaction would be committed to the storage, i'd > like to cycle through all dirty objects and reindex them, if they're > catalogpathaware (or implement reindex_object()...). > > > > > HTH > > > > Jonathan > > juergen > _______________________________________________________________________ > > >> XLhost.de - eXperts in Linux hosting << > > Juergen Herrmann > Weiherweg 10, 93051 Regensburg, Germany > Fon: +49 (0)700 XLHOSTDE [0700 95467833] > Fax: +49 (0)721 151 463027 > > ICQ: 27139974 - IRC: [EMAIL PROTECTED] > WEB: http://www.XLhost.de > _______________________________________________ > Zope maillist - Zope@zope.org > http://mail.zope.org/mailman/listinfo/zope > ** No cross posts or HTML encoding! ** > (Related lists - > http://mail.zope.org/mailman/listinfo/zope-announce > http://mail.zope.org/mailman/listinfo/zope-dev ) > -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )