[Zope3-dev] ContextMethod / Wrapper questions...

Brian Lloyd brian@zope.com
Thu, 26 Dec 2002 20:04:22 -0500


Hi all - 

I'm working on the C implementation of ContextMethod, etc., and 
I have a few questions for whoever knows the most about this 
(Steve?).

Right now, the Python implementation exposes Wrapper, which 
is really a function that might return one of 4 subclasses 
of the real Wrapper, depending on whether the class implements 
__call__, __getitem__, etc.

Is there any reason why we wouldn't want the real Wrapper class 
to Do The Right Thing if it can tell that a descriptor is a 
ContextMethod / ContextProperty? That seems like the simplest 
thing to do, but I wanted to make sure there isn't anything that 
expects to use the Wrapper C type directly with its current 
behavior (that doesn't understand descriptors that want context).

The change would basically be:

  - add ContextMethod descriptor type

  - add ContextProperty, ContextGetProperty, ContextSetProperty
    descriptor types

  - add overrides for the tp_getattro, tp_setattro, tp_call, 
    mp_subscript, mp_ass_subscript slots on the Wrapper type.

    These basically just check (efficiently) whether the 
    attr / slot implementation on the unwrapped object is 
    a context descriptor, and if so passes the wrapped self 
    rather than the stripped self.


Most of it is done already, I just need to know the right way to 
put it together (whether the right thing to do is to enhance the 
current Wrapper type or whether there is still a reason to have 
a separate MethodWrapper type).



Brian Lloyd        brian@zope.com
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com