Back to index

plone3  3.1.7
interfaces.py
Go to the documentation of this file.
00001 from zope.interface import Interface, Attribute
00002 from zope import schema
00003 
00004 from zope.app.container.interfaces import IContained
00005 from zope.app.container.interfaces import IOrderedContainer
00006 from zope.app.container.interfaces import IContainerNamesContainer
00007 
00008 from zope.app.container.constraints import contains
00009 from zope.annotation.interfaces import IAttributeAnnotatable
00010 
00011 class StopRule(Exception):
00012     """An event that informs us that rule execution should be aborted.
00013     """
00014     
00015     def __init__(self, rule):
00016         self.rule = rule
00017 
00018 class IRuleStorage(IOrderedContainer, IContainerNamesContainer):
00019     """A storage for rules. This is registered as a local utility.
00020     """
00021     contains('plone.contentrules.rule.interfaces.IRule')
00022     
00023     active = schema.Bool(title=u"Rules in this storage are active")
00024     
00025 class IRuleAssignable(IAttributeAnnotatable):
00026     """Marker interface for objects that can be assigned rules
00027     """
00028     
00029 class IRuleAssignment(IContained):
00030     """An assignment of a rule to a context
00031     """
00032     
00033     __name__ = schema.TextLine(title=u"The id of the rule")
00034     
00035     enabled = schema.Bool(title=u"Whether or not the rule is currently enabled")
00036     bubbles = schema.Bool(title=u"Whether or not the rule will apply to objects in subfolders")
00037     
00038 class IRuleAssignmentManager(IOrderedContainer):
00039     """An object that is capable of being assigned rules.
00040     
00041     Normally, an object will be adapted to IRuleAssignmentManager in order 
00042     to manipulate the rule assignments in this location.
00043     """
00044 
00045     def getRules(event, bubbled=False):
00046         """Get all enabled rules registered for the given event and
00047         assigned to this context. If bubbled is True, only rules that are
00048         bubbleable will be returned.
00049         """ 
00050 
00051 class IRuleExecutor(Interface):
00052     """An object that is capable of executing rules.
00053     
00054     Typically, a content object will be adapted to this interface
00055     """
00056     
00057     def __call__(event, bubbled=False, rule_filter=None):
00058         """Execute all rules applicable in the current context
00059         
00060         event is the triggering event. bubbled should be True if the rules
00061         are being executed as part of a bubbling up of events (i.e. this
00062         is a parent of the context where the event was triggered). filter,
00063         if given, is a callable that will be passed each rule in turn and
00064         can vote on whether it should be executed by returning True or
00065         False. It should take the arguments (context, rule, event).
00066         """