[Zope-CMF] How do I get the action for 'folderContents'?
Grégoire Weber
gregoire.weber@switzerland.org
Thu, 04 Apr 2002 00:19:59 +0200
Hi Tres,
hi all,
tanks for your snippet and your prompt answer, it guided me to the working
solution below.
> There isn't any API for fetching a single action information object
> from the tool; we should perhaps add one. As a workaround, try::
>
> actions = context.portal_actions.listFilteredActionsFor( context )
> fc_actions = map( lambda x: x['id'] == 'folderContents', actions=
)
> if fc_actions:
> fc_action = fc_actions[0]
The follwing snippet works for CVS-Versions of march 2002 (post CMF 1.2):
<CODE>
# workaround: get the absolute action path of an action not registered by an
# object in the portal_types tool like the 'folderContents' action:
actions_list = []
for actions in
context.portal_actions.listFilteredActionsFor(context).values():
actions_list.extend(actions)
action_path = filter(lambda x:x['id'] == 'folderContents',
actions_list)[0]['url']
# just for information (normal way): get an action of an object registered
# with the object:
action_path = context.getTypeInfo().getActionbyId('edit')
</CODE>
Greg
_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org