[Zope] Losing acquisition wrapping between method calls

LabuComp labucomp at global.co.za
Wed Feb 4 17:15:20 EST 2004


I get a problem where "self" loses it's acquisition wrapping between method
calls.

It happens as follows:

Defintion:
==========


class MyClass(CatalogAware, SimpleItem):
   # snip

def fancySetattr(self, attrName, attrValue):
    self.__dict__['_dyn_%s' %attrName] = attrValue
    self.reindex_object()

MyClass.__setattr__ = fancySetattr


Usage:
======

#get MyClass instance
myInstance = folder.restrictedTraverse("Instance1")
myInstance.aq_parent #works ok

myInstance.name = "John"


Problem:
========
when stepping into the above code, I end up, as expected, in fancySetattr
with "self" being myInstance.  All is fine, except for the fact that "self"
is no longer acquisition wrapped thus the self.reindex_object() line does
not work as it is dependant on being able to acquire the catalog, which it
can't.

Why does myInstance lose it's acquisition wrapper once it is passed to
fancySetattr as "self"?  Is there a way to re-wrap it or not lose the
wrapping at all?

Any help would be appreciated!
Etienne

Running Zope2.7 rc1 on Window 2000 with Python 2.3.3 (Windows binary dist)




More information about the Zope mailing list