[Zope-CMF] is this tiny patch to CMFCore/Expression.py okay?

Chris Withers chris at simplistix.co.uk
Wed Jan 12 08:37:20 EST 2005


Dieter Maurer wrote:
>>As for Dieter's points 2 & 3, Florent actually answered both of those 
>>;-)  The Acquisition.aq_parent function isn't available in expressions. 
>>I think the closest you can get is "object.aq_parent or object"
> 
> You mean "object/aq_parent | object" (as path expression)?
> 
>    When "object.aq_parent" does not result in an "AttributeError 'aq_parent'",
>    it is most likely what you are looking for.

I've lost context on this, but I'm fairly sure I meant what I said. That 
said, I can't see why the path expression wouldn't work, unless 
object.aq_parent is None in some circumstances...

> Almost surely, unless you use objects that are not acquisition wrapped.

...which I believe some things in CMF do, maybe DCWorkflow or some other 
bits and pieces?

>   I doubt that non acquisition wrapped objects are really useful
>   as main object in an expression context -- unless you are
>   using them outside Zope.

...no, but this code is used in lots of places.

>   But when your objects are not acquisition wrapped, "parent"
>   makes no sense at all (at least with the implementation
>   via acquisition).

indeed.

>   Therefore, we have another objection against the use of the
>   term "parent": the proposed value bound to the name has
>   nothing to do with the notion "parent" when the object is not
>   acquisition wrapped.

how so?
>>Florent suggested aq_parent(aq_inner(object)), but I think that's 
>>already available through the name 'folder'.
> 
> I wrote that but I have been wrong:
> 
>   Actually "folder" is the nearest folder at or above "object" (or
>   "None" if it is cannot be determined).
> 
>   Thus, often "folder" is the same as "aq_parent(aq_inner(object))"
>   but not always. Especially, it is not when "object" is
>   itself a folder.
> 
> However, I expect that in almost all use cases for your new
> "parent" you could use "folder" instead. Am I right?

Nope, "folder" is roughly "container", I want something closer to 
"context"...

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the Zope-CMF mailing list