[Zope-CMF] Re: Inconstancy with CA traversal

Laurence Rowe l at lrowe.co.uk
Wed Jun 25 05:13:51 EDT 2008


Wichert Akkerman wrote:
> Previously Dylan Jay wrote:
>> I've observed an unexpected effect that you can override a skin based 
>> template or python script with a browser view in a sub folder but not at 
>> the portal root.
>> I'm trying to get my head round all the various traversal code in 
>> zope/five and would appreciate any tips from someone who knows this code 
>> well.
> 
> For some unknown reason CMF explicitly encoded that behaviour in
> __bobo_traverse__. It's bitten Plone as well.

As far as I can tell, it's not actually encoded in __bobo_traverse__ but 
in the interactions between Skinnable.__getattr__ and OFS.Traversable.

OFS.Traversable.unrestrictedTraverse looks up objects in the following 
order:

  1. namespaces (@@ and ++)

  2. bobo_traverse

  3. getattr(aq_base(obj), name) # no acquisition

  4. views

  5. getattr(obj, name) # with acquisition

The difference in behaviour occurs because at the portal root skin 
objects get picked up at number 3, whereas in other places they get 
picked up at number 5, after views.

To fix this we need to add a __bobo__traverse__ method to Skinnable that 
looks up objects in the order:

  1. getattr(aq_base(obj), name), but excluding skin objects

  2. views

  3. getattr(aq_base(obj), name), including skin objects

  4. getattr(obj, name)

Laurence



More information about the Zope-CMF mailing list