E&S CVS Commit: PEAK - Finally got rid of 'x.__class__.foo(x,...)' hacks! Now, if a metaclass

pje at eby-sarna.com pje at eby-sarna.com
Sat May 3 10:33:00 EDT 2003


Module Name:	PEAK
Committed By:	pje
Date:		Sat May  3 14:32:24 UTC 2003

Modified Files:
	PEAK: CHANGES.txt
	PEAK/src/peak/binding: components.py once.py

Log Message:
Finally got rid of 'x.__class__.foo(x,...)' hacks!  Now, if a metaclass
needs to have a method that one of its instances might also have as an
instance method, you can wrap it with 'binding.metamethod(foo)'.  This
is nice and clean because it doesn't force every caller of the 'foo'
method to try and guess whether it's working with a class or an instance.
Even nicer, this solution requires no special work by the person writing
these methods, unless the method is going into a metaclass, and even then
they need only wrap it with 'metamethod'.

Last, but not least, this cleans up some of our __class__ usage so that
we'll be able to work correctly with 'zope.security'.  As far as I know,
the 'x.__class__.foo(x,..)' trick wouldn't have worked consistently when
'x' was a proxied object, whereas a normal call to 'foo' would properly
pass through the proxy barrier as long as the caller had permission to
access 'foo'.

(Note: at the moment 'foo' translates to the 'getParentComponent',
'_getConfigData', 'getComponentName', and 'notifyUponAssembly' methods.)


To view diffs of this commit, you can use the following URL(s):
http://cvs.eby-sarna.com/PEAK/CHANGES.txt.diff?r1=1.20&r2=1.21
http://cvs.eby-sarna.com/PEAK/src/peak/binding/components.py.diff?r1=1.103&r2=1.104
http://cvs.eby-sarna.com/PEAK/src/peak/binding/once.py.diff?r1=1.42&r2=1.43

To generate a diff of this commit:
cvs rdiff -r1.20 -r1.21 PEAK/CHANGES.txt
cvs rdiff -r1.103 -r1.104 PEAK/src/peak/binding/components.py
cvs rdiff -r1.42 -r1.43 PEAK/src/peak/binding/once.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




More information about the source-changes mailing list