Back to index

plone3  3.1.7
WorkflowCore.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ Common pieces of the workflow architecture.
00014 
00015 $Id: WorkflowCore.py 71686 2007-01-02 14:51:01Z tseaver $
00016 """
00017 
00018 from zope.interface import implements
00019 from zope.component.interfaces import ObjectEvent
00020 
00021 from Products.CMFCore.interfaces import IWorkflowActionEvent
00022 from Products.CMFCore.interfaces import IActionWillBeInvokedEvent
00023 from Products.CMFCore.interfaces import IActionRaisedExceptionEvent
00024 from Products.CMFCore.interfaces import IActionSucceededEvent
00025 
00026 class WorkflowException( Exception ):
00027 
00028     """ Exception while invoking workflow.
00029     """
00030     
00031 
00032 class ObjectDeleted( Exception ):
00033 
00034     """ Raise to tell the workflow tool that the object has been deleted.
00035 
00036     Swallowed by the workflow tool.
00037     """
00038     def __init__(self, result=None):
00039         self._r = result
00040 
00041     def getResult(self):
00042         return self._r
00043 
00044 
00045 class ObjectMoved( Exception ):
00046 
00047     """ Raise to tell the workflow tool that the object has moved.
00048 
00049     Swallowed by the workflow tool.
00050     """
00051     def __init__(self, new_ob, result=None):
00052         self._ob = new_ob  # Includes acquisition wrappers.
00053         self._r = result
00054 
00055     def getResult(self):
00056         return self._r
00057 
00058     def getNewObject(self):
00059         return self._ob
00060 
00061 # Events
00062 
00063 class WorkflowActionEvent(ObjectEvent):
00064     implements(IWorkflowActionEvent)
00065     
00066     def __init__(self, object, workflow, action):
00067         ObjectEvent.__init__(self, object)
00068         self.workflow = workflow
00069         self.action = action
00070     
00071 class ActionWillBeInvokedEvent(WorkflowActionEvent):
00072     implements(IActionWillBeInvokedEvent)
00073 
00074             
00075 class ActionRaisedExceptionEvent(WorkflowActionEvent):
00076     implements(IActionRaisedExceptionEvent)
00077     
00078     def __init__(self, object, workflow, action, exc):
00079         WorkflowActionEvent.__init__(self, object, workflow, action)
00080         self.exc = exc
00081     
00082 class ActionSucceededEvent(WorkflowActionEvent):
00083     implements(IActionSucceededEvent)
00084     
00085     def __init__(self, object, workflow, action, result):
00086         WorkflowActionEvent.__init__(self, object, workflow, action)
00087         self.result = result
00088