Back to index

plone3  3.1.7
Classes | Functions | Variables
plone.app.contentrules.handlers Namespace Reference

Classes

class  DuplicateRuleFilter

Functions

def init
def close
def execute
def is_portal_factory
def added
def archetypes_initialized
def removed
def modified
def workflow_action

Variables

tuple _status = zope.thread.local()

Function Documentation

When an object is added, execute rules assigned to its new parent.

There is special handling for Archetypes objects.

Definition at line 122 of file handlers.py.

00122 
00123 def added(event):
00124     """When an object is added, execute rules assigned to its new parent.
00125 
00126     There is special handling for Archetypes objects.
00127     """
00128     if is_portal_factory(event.object):
00129         return
00130     
00131     # The object added event executes too early for Archetypes objects.
00132     # We need to delay execution until we receive a subsequent IObjectInitializedEvent
00133     
00134     if not IBaseObject.providedBy(event.object):
00135         execute(event.newParent, event)
00136     else:
00137         init()
00138         _status.delayed_events[IObjectInitializedEvent] = event

Here is the call graph for this function:

Pick up the delayed IObjectAddedEvent when an Archetypes object is
initialised.

Definition at line 139 of file handlers.py.

00139 
00140 def archetypes_initialized(event):
00141     """Pick up the delayed IObjectAddedEvent when an Archetypes object is
00142     initialised.
00143     """
00144     if is_portal_factory(event.object):
00145         return
00146     
00147     if not IBaseObject.providedBy(event.object):
00148         return
00149 
00150     init()
00151     delayed_event = _status.delayed_events.get(IObjectInitializedEvent, None)
00152     if delayed_event is not None:
00153         _status.delayed_events[IObjectInitializedEvent] = None
00154         execute(delayed_event.newParent, delayed_event)
        

Here is the call graph for this function:

Close the event processing when the request ends

Definition at line 53 of file handlers.py.

00053 
00054 def close(event):
00055     """Close the event processing when the request ends
00056     """
00057     if hasattr(_status, 'rule_filter'):
00058         _status.rule_filter.reset()
00059     if hasattr(_status, 'delayed_events'):
00060         _status.delayed_events = {}
    

Here is the caller graph for this function:

def plone.app.contentrules.handlers.execute (   context,
  event 
)
Execute all rules relative to the context, and bubble as appropriate.

Definition at line 61 of file handlers.py.

00061 
00062 def execute(context, event):
00063     """Execute all rules relative to the context, and bubble as appropriate.
00064     """
00065     
00066     # Do nothing if there is no rule storage or it is not active
00067     storage = queryUtility(IRuleStorage)
00068     if storage is None or not storage.active:
00069         return
00070     
00071     init()
00072     
00073     rule_filter = _status.rule_filter
00074     
00075     # Stop if someone else is already executing. This could happen if,
00076     # for example, a rule triggered here caused another event to be fired.
00077     if rule_filter.in_progress:
00078         return
00079         
00080     # Tell other event handlers to be equally kind
00081     rule_filter.in_progress = True
00082     
00083     # Prepare to break hard if a rule demanded execution be stopped
00084     try:
00085     
00086         # Try to execute rules in the context. It may not work if the context
00087         # is not a rule executor, but we may still want to bubble events
00088         executor = IRuleExecutor(context, None)
00089         if executor is not None:
00090             executor(event, bubbled=False, rule_filter=rule_filter)
00091     
00092         # Do not bubble beyond the site root
00093         if not ISiteRoot.providedBy(context):
00094             parent = aq_parent(aq_inner(context))
00095             while parent is not None:
00096                 executor = IRuleExecutor(parent, None)
00097                 if executor is not None:
00098                     executor(event, bubbled=True, rule_filter=rule_filter)
00099                 if ISiteRoot.providedBy(parent):
00100                     parent = None
00101                 else:
00102                     parent = aq_parent(aq_inner(parent))
00103 
00104     except StopRule:
00105         pass
00106     
00107     # We are done - other events that occur after this one will be allowed to
00108     # execute rules again
00109     rule_filter.in_progress = False
00110 
00111     
00112 # Event handlers

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 47 of file handlers.py.

00047 
00048 def init():
00049     if not hasattr(_status, 'rule_filter'):
00050         _status.rule_filter = DuplicateRuleFilter()
00051     if not hasattr(_status, 'delayed_events'):
00052         _status.delayed_events = {}

Here is the caller graph for this function:

Find out if the given object is in portal_factory

Definition at line 113 of file handlers.py.

00113 
00114 def is_portal_factory(context):
00115     """Find out if the given object is in portal_factory
00116     """
00117     portal_factory = getToolByName(context, 'portal_factory', None)
00118     if portal_factory is not None:
00119         return portal_factory.isTemporary(context)
00120     else:
00121         return False

Here is the call graph for this function:

Here is the caller graph for this function:

When an object is modified, execute rules assigned to its parent

Definition at line 165 of file handlers.py.

00165 
00166 def modified(event):
00167     """When an object is modified, execute rules assigned to its parent
00168     """
00169     
00170     if is_portal_factory(event.object):
00171         return
00172     
00173     # Let the special handler take care of IObjectInitializedEvent
00174     if not IObjectInitializedEvent.providedBy(event):
00175         execute(aq_parent(aq_inner(event.object)), event)
        

Here is the call graph for this function:

When an IObjectRemevedEvent was received, execute rules assigned to its
 previous parent.

Definition at line 155 of file handlers.py.

00155 
00156 def removed(event):
00157     """When an IObjectRemevedEvent was received, execute rules assigned to its
00158      previous parent.
00159     """
00160     
00161     if is_portal_factory(event.object):
00162         return
00163         
00164     execute(event.oldParent, event)
    

Here is the call graph for this function:

When a workflow action is invoked on an object, execute rules assigned
to its parent.

Definition at line 176 of file handlers.py.

00176 
00177 def workflow_action(event):
00178     """When a workflow action is invoked on an object, execute rules assigned
00179     to its parent.
00180     """
00181     
00182     if is_portal_factory(event.object):
00183         return
00184     
00185     execute(aq_parent(aq_inner(event.object)), event)

Here is the call graph for this function:


Variable Documentation

tuple plone.app.contentrules.handlers._status = zope.thread.local()

Definition at line 45 of file handlers.py.