[Zope3-dev] ConextMethod confusion

Jeremy Hylton jeremy@alum.mit.edu
Tue, 3 Dec 2002 15:54:32 -0500


I got side-tracked today trying to figure out why a test was failing
and looked at the ContextMethod code.  I wanted to ask some questions
by email, because IRC didn't seem the right venue for design
questions. 

There are two confusing things about the current implementation.  The
first is that there is a module named SimpleMethodWrapper.  I find
this confusing because 1) the objects in it don't wrap methods and 2)
Python has a builtin method-wrapper that does wrap methods.  It
appears that SimpleMethodWrapper wraps an object so that something
special happens to some method lookups.

I'm not sure what a better name would be perhaps just SimpleWrapper or
Wrapper?  The fact that the module lives in Zope.ContextMethod gives
some indication of its purposes without putting the "Method" decoy in
its name.

> from wrapper import *
...
> from SimpleMethodWrapper import wrapperCreator as Wrapper

It's also confusing that the import * defines a Wrapper which is
immediately overridden by another import of Wrapper which is defined
by something that isn't even call Wrapper.  What names is the import *
actually trying to put in the namespace?  Perhaps clients should get
those names explicitly via Zope.ContextMethod.wrapper?  I also think
the name in SimpleMethodWrapper should match the name in __init__.
Can it be renamed to Wrapper in SimpleMethodWrapper?  If it can't, I
think that just illustrates why it is so confusing :-).

Jeremy