[Product-Developers] Re: Traversing to an object like the publisher does

Tom Gross itconsense at gmail.com
Fri May 15 11:40:47 UTC 2009


Hi Jan,

try:
   pcs = getMultiAdapter((self.context, self.request),
                         name="plone_context_state")
   self.request.traverseName(pcs, 'is_view_template')
except:
   try:
       self.request.traverse('plone_context_state/is_view_template')
   except:
       I have no other idea.

this is untestet, just from the top of my head.

Cheers
-Tom


Jan Hackel wrote:
> On Thursday 14 May 2009 Jan Hackel wrote:
>>>> I need to write a test that essentially needs to traverse to an
>>>> operation like the following tal-expression would:
>>>>
>>>> tal:condition="context/@@plone_context_state/is_view_template"
>>> context.restrictedTraverse('@@plone_context_state').is_view_template()
>>>
>>> Hedley
>> Well, thanks! While I am pretty sure I tried that, it now works...
> 
> I was a bit to fast with celebrations. The problem with "restrictedTraverse" 
> is that it will not trigger registered IPublishTraverse adapters. I need those 
> however. Any other suggestions?
> 
> Grüße
> Jan Hackel





More information about the Product-Developers mailing list