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

Garrett Smith garrett at mojave-corp.com
Wed Mar 9 10:52:03 EST 2005


Jim Fulton wrote:
> 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?

Yes

> ...
> 
>> 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.

It's not a big deal -- I just didn't know this feature existed. My
nervousness is similar to that when I use the page directive to hookup
context and request -- looking at the code it's not obvious how
something works. Not a biggie though.

 -- Garrett


More information about the Zope3-dev mailing list