[Zope3-dev] Form framework, adapters and pau

Dominik Huber dominik.huber at projekt01.ch
Wed Apr 20 07:17:56 EDT 2005


Excuse me late response I was busy that weekend...

Jim Fulton wrote:

>> I fixed that issue within the branch 
>> 'Zope3/branches/dominik-locatableadapters'
>> Jim, could you take a look at that please. Thank you very much in 
>> advance!
>
>
[...]

>
> We should *only* add the location if the adapter requires a permission 
> other
> than zope public.  Key rereferences don't require a permission and 
> should not
> be location proxied. Doing so makes them unpicklable.
>
> We're going to need to fix the trusted adapter factory to do this 
> correctly.
> I suggest we create a new kind of trusted adapter factory, perhaps
> "LocatingTrustedAdapter" factory that adds the location. This should
> only be used when the adapter directive specified a permission other
> than zope.Public. Otherwise, the original trusted adapter factory should
> be used.

May be I do not understand the problem correctly:

IMO the permission declaration within the adapter directive has nothing 
to do
with the permission declaration wihtin the class directive that mus be 
used if
trusted adapters are invoked.

Example KeyReference Adapter:

  <adapter
      for="persistent.interfaces.IPersistent"
      provides=".interfaces.IKeyReference"
      factory=".persistent.KeyReferenceToPersistent"
      trusted="y"
      />

  <class class=".persistent.KeyReferenceToPersistent">
    <require permission="zope.Public" 
interface=".interfaces.IKeyReference" />
  </class>

So, during the registration of an trusted adapter  factory (<adapter...) 
I can't do any prediction about the
permission declaration of the possible adapter instances (<class ...). 
Therefore we can't switch the
adapter factories within the adapter directive processing..

All the same I implemented your sugestion. The following question appears:
- How should we handle NullAdapters correctly?

IMO this solution is pretty implicit and I do not like it at all.
We should find a way to check the permission of the adapter instances 
inside a single trusted adapter factory:

class IntelligentTrustedAdapterFactory(TrustedAdapterFactoryMixin):

    def _customize(self, adapter, context):
        p = ProxyFactory(adapter)
        checker = getChecker(p)
        if checker is CheckerPublic:
            return adapter
        else:
           return assertLocation(adapter, context)

Questions:
- performance
- in the key refernce example it would be an dedicated checker. how 
could I guess if such an checker is Public?

>
> Of course, you should revert the change to key references.

Done

[...]

>
> P.S. Please make sure source lines are 79 characters or less in 
> lengnth. :)

Ok

Thank you for the comments!
Regard,
Dominik



More information about the Zope3-dev mailing list