What is the meaning self = self.this() Sedat Yilmazer Kibele Iletisim Sis. ve Serv. Ltd.
Well, as I realised only yesterday, sometimes 'self' is not equal to 'this()' ;) this() is defined by the Item baseclass and indeed looks like def this(): return self Not all objects are Items though, and for example when creating a custom user folder, I had to put in its factory method (manage_addXYZ): self.this().__allow_groups__ = mynewuserfolderobject The reason is that, while in the factory method, self does not refer to an ObjectManager, but to a __FactoryDispatcher__ class. Using self.this() will return the self *of the nearest Item subclass*; the desired ObjectManager in my case. Note that a call like self.this() is subject to aquisition! Regards, Stefan On Mon, 25 Jun 2001, Sedat Yilmazer wrote:
What is the meaning
self = self.this()
Sedat Yilmazer Kibele Iletisim Sis. ve Serv. Ltd.
"Sedat Yilmazer" <sedat@kibele.com> writes:
What is the meaning self = self.this()
Whenever you call an acquired normal method, then part of the acquisition context is stripped from the passed in "self" such that "self.aq_self" is the object, that defines the method (i.e. it does not acquired it). Therefore, despite the definition, def this(self): return self self= self.this() has an effect: After the assignment, "self" is an object that defines the "this" method and no longer an object that only acquires it. In a standard Zope setup, "this" is defined by the Zope site building objects (Folder, Script, DTML object, ...) and not by auxiliary classes. In this case, you can use "this()" to get at the nearest Zope site building object. Dieter
participants (3)
-
Dieter Maurer -
Sedat Yilmazer -
Stefan H. Holek