[Zope] reindex_object in __setattr__ method not working. (was: Losing acquisition wrapping between method calls)

Etienne Labuschagne elabuschagne at gmsonline.co.za
Thu Feb 5 02:59:39 EST 2004


Hi there,

I am using __setattr__ in my class to decide if the class needs to be 
reindexed or not.  The problem is, the moment you enter the __setattr__ 
method, self is not acquisition wrapped anymore, which means that 
reindex_object does not work since it cannot acquire the Catalog.

This can be illustrated with the following small test class:

class AQTest(CatalogAware, SimpleItem):
     '''Test class'''
     meta_type = "Health Window Test"

     def __setattr__(self, attrName, attrValue):
         if attrName.startswith('abc'):
             self.reindex_object()  #This doesn't work, since self is no 
longer acquisition wrapped here, eg. self.aq_parent raises an error
         self.__dict__[attrName] = attrValue

     def test(self):
         '''Test method'''
         self.abcname = 'John'


Any suggestions on how to fix this?

Etienne




More information about the Zope mailing list