user657127
user657127

Reputation:

Plone 4: How to define a Content action url_expr that redirects to objects parent container

I have a (dexterity) content type that defines the following action.

<action title="Search" 
        action_id="search" 
        category="object" 
        condition_expr=""
        url_expr="python:aq_parent(aq_inner(context))" 
        visible="True">
        <permission value="View"/>
</action>

url_expr contains, what I try to get, but I get a NameError. I imported the functions from Acquisition in the corresponding content class, but that did not help.

Any hints? Thanks in advance.

Update I

I tried the suggested solution, but that leads to the following trace (urls cropped):

http://pastie.org/6100541

So I switched back to my solution. Bug or feature?

Upvotes: 2

Views: 133

Answers (2)

keul
keul

Reputation: 7819

aq_parent and aq_inner functions are not available there, but you can use:

python:context.aq_inner.aq_parent

Upvotes: 2

user657127
user657127

Reputation:

Asking helps!

I got this idea just a few minutes after asking ;)

[...]
url_expr="python:'/'.join(object_url.split('/')[0:-1])"
[...]

Seems a bit hacked to me and in this form does not deal with GET stuff. Any better ideas or recommendations still welcome.

Upvotes: 0

Related Questions