[Zope3-dev] path adapters

Jean-Marc Orliaguet jmo at ita.chalmers.se
Sun Sep 11 15:36:09 EDT 2005


Stephan Richter wrote:

>On Sunday 11 September 2005 11:32, Jean-Marc Orliaguet wrote:
>  
>
>>it there any technical reason why:
>>
>>   tal:define="displayable nocall:context/displayable"
>>
>>could not return the adapted object based on the context instead of
>>triggering a traversal error?
>>    
>>
>
>Yes. You are not using the path adapter syntax as far as I can see. You need 
>to have: object/path_adapter_name:function
>
>You should check the parsing implementation (probably some traversing code) to 
>see about the assumptions.
>
>Regards,
>Stephan
>  
>

I know that, I was about to file this as a bug, or write a proposal to let

tal:define="adapted nocall:object/path_adapter_name"

return the adapted object, but I found a workaround, by adding:

    def this(self):
        """Return the adapted object.
        """
        return self

to the adapter. Now I can use instead:

tal:define="
    displayable context/displayable:this;
    display python: displayable.getDisplay(perspective)"
"

which in terms of performance means that I don't need doing an adapter
lookup for each of the adapter's method that I want to call. That is a
pretty straightforward optimization.

still it feels like an unnecessarily complicated way of doing something
simple.

/JM



More information about the Zope3-dev mailing list