[Zope] automagic reindexing of objects

Jürgen Herrmann Juergen.Herrmann at XLhost.de
Wed Jun 22 08:58:01 EDT 2005


hi all!

as i had time to look at all the stuff, i realized, that i'm
getting closer, but this is not exactly what i wanted...

as i can see from the path, one has to call:
    beforeCommitHook(method, **args, **kwargs)
on each transaction, correct?
this is contrary to my idea of everything doing it's work "automagically".

what i want is a kind of callback to each dirty object, something like
this:

class Transaction(...):
  def commit(self, ...):
    # insert this:
    for object in self._objects:
      try:
        object._before_transaction_commit()
      except AttributeError:
        pass
    # rest of original commit() follows...

could this impose any unforseen behaviour?
btw: what version of the two following is better (i.e. faster and more
elegeant, i do python coding since abt. 6months only...)

      try:
        object._before_transaction_commit()
      except AttributeError:
        pass

or
      hook = object.get('_before_transaction_commit', None)
      if hook: hook()

another question: is it hook() or hook(object) in the previous line?
i never know if the self parameter has to be passed in if not called
as self.method() - are there any (simple) rules?

regards, juergen herrmann

[ Florent Guillaume wrote:]
> Dieter Maurer  <dieter at handshake.de> wrote:
>> Jürgen Herrmann wrote at 2005-6-17 14:19 +0200:
>> >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.
>> >
>> >is it possible? where should i start looking in the source, is there
>> >possibly a before_transaction_commit hook?
>>
>> It is impossible with "ZODB 3.2" (unless you patch
>> "ZODB.Transaction.Transaction").
>
> The CPSCompat module of CPS has monkey-patches that backport this from
> ZODB 3.4, among others, to be used in Zope 2.7.
>
> http://svn.nuxeo.org/trac/pub/file/CPSCompat/trunk/PatchZODBTransaction.py
>
> Florent
>
>> "ZODB 3.4" (which is used for Zope 2.8/3.1) has hooks
>> that makes it possible.
>
>
> --
> Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
> +33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com
> _______________________________________________
> Zope maillist  -  Zope at 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 )
>


_______________________________________________________________________

>> 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: #XLhost at quakenet
WEB:  http://www.XLhost.de


More information about the Zope mailing list