Jeff Rush wrote:

My specific question is how evaluation of the path expression "X/Z" is handled. It *seems* to be:

    X.__getitem__('Y')    # X['Y']

whereas I'm trying to get:

    X.__getattr__('Y')    # X.Y

Under Zope 2, as I recall, it would try several algorithms; attribute, mapping, sequence. And I'm wondering if that mechanism was simplified for Zope 3, and in what way.

My approach of using attr: and item: TALES namespace adapters doesn't work in all cases, since those TAL templates not under my control, for ZMI, access the attribute/item namespaces using the old ordering.

So another approach is to override the traversal algorithm for selected classes of objects.

There are (at least) two traversal algorithms, one that seaches the item namespace first then the attribute namespace, and one that does it in the other order.  (attr then item) (item then attr)

Therefore I didn't need to write my own traverser, just select the non-content style for those containers that needs the other order.

So for my IVenture container class, I do:



And the old search order is now 'attr then item'!

I thought this technique might useful to someone.


Zope3-users mailing list

Reply via email to