Back to index

plone3  3.1.7
Public Member Functions
CMFFormController.Actions.RedirectToAction.RedirectToAction Class Reference
Inheritance diagram for CMFFormController.Actions.RedirectToAction.RedirectToAction:
Inheritance graph
[legend]
Collaboration diagram for CMFFormController.Actions.RedirectToAction.RedirectToAction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __call__

Detailed Description

Definition at line 12 of file RedirectToAction.py.


Member Function Documentation

Definition at line 14 of file RedirectToAction.py.

00014 
00015     def __call__(self, controller_state):
00016         action = self.getArg(controller_state)
00017         action_url = None
00018         haveAction = False
00019 
00020         context = controller_state.getContext()
00021         fti = context.getTypeInfo()
00022 
00023         try:
00024             # Test to see if the action is defined in the FTI as an object or
00025             # folder action
00026             action_ob = fti.getActionObject('object/'+action)
00027             if action_ob is None:
00028                 action_ob = fti.getActionObject('folder/'+action)
00029             action_url = action_ob.getActionExpression()
00030             haveAction = True
00031         except (ValueError, AttributeError):
00032             actions_tool = getToolByName(context, 'portal_actions')
00033             actions = actions_tool.listFilteredActionsFor(
00034                                                 controller_state.getContext())
00035             # flatten the actions as we don't care where they are
00036             actions = reduce(lambda x,y,a=actions:  x+a[y], actions.keys(), [])
00037             for actiondict in actions:
00038                 if actiondict['id'] == action:
00039                     action_url = actiondict['url'].strip()
00040                     haveAction = True
00041                     break
00042 
00043         # (note: action_url may now be an emptry string, but still valid)
00044         if not haveAction:
00045             raise ValueError, 'No %s action found for %s' % (action, controller_state.getContext().getId())
00046 
00047         # XXX: Is there a better way to check this?
00048         if not action_url.startswith('string:'):
00049             action_url = 'string:%s' % (action_url,)
00050         return RedirectTo.RedirectTo(action_url)(controller_state)
00051 
00052 registerFormAction('redirect_to_action',
00053                    factory,
00054                    'Redirect to the action specified in the argument (a TALES expression) for the current context object (e.g. string:view)')

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: