[Zope3-dev] ILocation code in zope/app/form/editview.py

Jim Fulton jim at zope.com
Tue Mar 8 19:27:20 EST 2005


Garrett Smith wrote:
> Gary Poster wrote:
> 
...

>>If the adapter is trusted and implements ILocation, the trusted
>>adapter factory will set the __parent__ and __name__ itself. 
> 
> 
> Does this happen now?

Yes

 > I'm surprised that this would be hard-coded in the
> adapter factory.

It's in the zcml directive handler, not in the underlying
adapter machinery.  Using trusted="1" in the adapter directive
effectively causes the factory to be adapted to a factory
that caused the adapter to be proxied rather than the original
object and that sets the __parent__ if the adapter is an ILocation.
The later is a debatable convenience.

 > Why not just require the adapter to configure itself,
> if that's what it wants/needs to do?

You mean, why not have the adapter set it's own __parent__ in
it's constructor?

...

> I may be missing something, but I'm not comfortable with the seeming
> magic of setting __parent__ and __name__ if an adapter provides
> ILocation.

I'll have to think about that.  Generally, the only reason for
an adapter to provide ILocation is to get it's name set. ;)
But, I suppose an adapter could have a legitimate reason for having
a __parent__, in which case the current trusted-adapter-factory would
do harm.

For now, perhaps we should only set __parent__ if the current value is
not None.  If we decode that adapters should set their own __parent__s,
then we could eventually stop setting it in the trusted adapter factory,
although then we'd need to provide a deprecation warning if the trusted
adapter factory saw a None value.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-dev mailing list