Exemplo n.º 1
0
 def __call__(self, form, action, data):
     """Save data, make version and fire transition.
     
     Redirects to the ``next_url`` location.
     """
     context = getattr(form.context, "_object", form.context)
     if self.wf_name:
         info = component.getAdapter(context, interfaces.IWorkflowInfo,
                                     self.wf_name)
     else:
         info = interfaces.IWorkflowInfo(context)
     result = handle_edit_action(form, action, data)
     #
     if form.errors:
         return result
     else:
         # NOTE: for some reason form.next_url is (always?) None --
         # for when it is None, we redirect to HTTP_REFERER instead.
         log.debug(""" TransitionHandler.__call__()
     form=%s 
     action=(name=%s, label=%s)
     data=%s
     principal_id=%s
     context=%s
     transition_id=%s
     result=%s
     next_url=%s 
     current_url=%s """ % (form, action.label, action.name, data,
                           get_principal_id(), context, self.transition_id,
                           result, form.next_url, form.request.getURL()))
         # dress-up transition data object
         data.setdefault("note", data.get("note", ""))
         data.setdefault("date_active", data.get("data_active", None))
         # and because WorkflowInfo API e.g. fireTransition(), ONLY
         # foresees for a comment attribute as additional data, we bypass
         # using that altogether, and pass it along downstream by stuffing
         # onto the request
         IAnnotations(form.request)["change_data"] = data
         info.fireTransition(self.transition_id)
         next_url = form.next_url
         if next_url is None:
             next_url = form.request["HTTP_REFERER"]
             log.error(
                 " TransitionHandler.__call__() => CANNOT redirect to "
                 "next_url [None]... will try instead to redirect to "
                 "HTTP_REFERER [%s]" % (next_url, ))
         return form.request.response.redirect(next_url)
Exemplo n.º 2
0
 def __call__(self, form, action, data):
     """Save data, make version and fire transition.
     
     Redirects to the ``next_url`` location.
     """
     context = getattr(form.context, "_object", form.context)
     if self.wf_name:
         info = component.getAdapter(
             context, interfaces.IWorkflowInfo, self.wf_name)
     else:
         info = interfaces.IWorkflowInfo(context)
     result = handle_edit_action(form, action, data)
     #
     if form.errors: 
         return result
     else:
         # NOTE: for some reason form.next_url is (always?) None --
         # for when it is None, we redirect to HTTP_REFERER instead.
         log.debug(""" TransitionHandler.__call__()
     form=%s 
     action=(name=%s, label=%s)
     data=%s
     principal_id=%s
     context=%s
     transition_id=%s
     result=%s
     next_url=%s 
     current_url=%s """ % (form, action.label, action.name, data, 
             get_principal_id(), context, self.transition_id, 
             result, form.next_url, form.request.getURL()))
         # dress-up transition data object
         data.setdefault("note", data.get("note", ""))
         data.setdefault("date_active", data.get("data_active", None))
         # and because WorkflowInfo API e.g. fireTransition(), ONLY 
         # foresees for a comment attribute as additional data, we bypass 
         # using that altogether, and pass it along downstream by stuffing 
         # onto the request
         IAnnotations(form.request)["change_data"] = data
         info.fireTransition(self.transition_id)
         next_url = form.next_url
         if next_url is None:
             next_url = form.request["HTTP_REFERER"]
             log.error(" TransitionHandler.__call__() => CANNOT redirect to "
                 "next_url [None]... will try instead to redirect to "
                 "HTTP_REFERER [%s]" % (next_url,))
         return form.request.response.redirect(next_url)
Exemplo n.º 3
0
    def __call__(self, form, action, data):
        """Save data, make version and fire transition.

        Redirects to the ``next_url`` location.
        """

        context = getattr(form.context, "_object", form.context)
        notes = None
        if self.wf_name:
            info = component.getAdapter(context, interfaces.IWorkflowInfo, self.wf_name)
        else:
            info = interfaces.IWorkflowInfo(context)
        if data.has_key("note"):
            notes = data["note"]
        else:
            notes = ""
        result = handle_edit_action(form, action, data)
        if form.errors:
            return result
        else:
            info.fireTransition(self.transition_id, notes)
            return form.request.response.redirect(form.next_url)
Exemplo n.º 4
0
    def __call__( self, form, action, data ):
        """Save data, make version and fire transition.

        Redirects to the ``next_url`` location.
        """
        
        context = getattr( form.context, '_object', form.context )
        notes = None
        if self.wf_name:
            info = component.getAdapter(
                context, interfaces.IWorkflowInfo, self.wf_name)
        else:
            info = interfaces.IWorkflowInfo( context ) 
        if data.has_key('note'):
            notes = data['note']
        else:
            notes=''
        result = handle_edit_action( form, action, data )
        if form.errors: 
            return result
        else:
            info.fireTransition( self.transition_id, notes )
            return form.request.response.redirect(form.next_url)