[Zope] automagic reindexing of objects
Jürgen Herrmann
Juergen.Herrmann at XLhost.de
Fri Jun 17 10:54:06 EDT 2005
[ Peter Bengtsson wrote:]
> 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.
>
hmm, i can't see how this would help. if i call index_object in every
attribute getter method, the indexing is done possibly several times,
unnecessary and (cpu)time consuming.
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: #XLhost at quakenet
WEB: http://www.XLhost.de
More information about the Zope
mailing list