[Zope3-checkins] CVS: Zope3/src/zope/app - context.txt:1.7
Steve Alexander
steve@cat-box.net
Wed, 2 Jul 2003 16:54:10 -0400
Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv21282/src/zope/app
Modified Files:
context.txt
Log Message:
Added note about decorators calling context aware descriptors of proxied
objects, the consequences, and what we should do about it.
=== Zope3/src/zope/app/context.txt 1.6 => 1.7 ===
--- Zope3/src/zope/app/context.txt:1.6 Sat Jun 14 09:11:04 2003
+++ Zope3/src/zope/app/context.txt Wed Jul 2 16:54:05 2003
@@ -281,3 +281,25 @@
into context-aware descriptors through deriving new classes.
Such unpredictability and implicitness is bad.
+* Using ContextDescriptors from a decorator
+
+ Context decorators usually have methods that look like this:
+
+ def setObject(self, name, obj):
+ name = getProxiedObject(self).setObject(name, object)
+ # send events
+ # call hooks
+ return name
+
+ A problem with this is that getProxiedObject(self) will usually return
+ an unwrapped object. So, even if setObject on the proxied object is a
+ ContextDescriptor, it will not be called with 'self' rebound to the
+ wrapper instance.
+
+ The way around this is to write a special getProxiedObject that is the
+ moral equivalent to 'super', and does the right thing for context-aware
+ descriptors.
+
+ For now, though, a ContextDescriptor of an object must not be called from
+ its decorator.
+