Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 from zope.component import getAllUtilitiesRegisteredFor
00002 from plone.contentrules.rule.interfaces import IRuleCondition, IRuleAction
00003   
00004 def getAvailableConditions(context, eventType):
00005     conditions = getAllUtilitiesRegisteredFor(IRuleCondition)
00006     return [c for c in conditions if 
00007                 (c.event is None or eventType.isOrExtends(c.event)) and
00008                 (c.for_ is None or c.for_.providedBy(context))]
00009     
00010 def allAvailableConditions(eventType):
00011     conditions = getAllUtilitiesRegisteredFor(IRuleCondition)
00012     return [c for c in conditions if 
00013                 (c.event is None or eventType.isOrExtends(c.event))]
00014     
00015 def getAvailableActions(context, eventType):
00016     actions = getAllUtilitiesRegisteredFor(IRuleAction)
00017     return [a for a in actions if 
00018                 (a.event is None or eventType.isOrExtends(a.event)) and
00019                 (a.for_ is None or a.for_.providedBy(context))]
00020     
00021 def allAvailableActions(eventType):
00022     actions = getAllUtilitiesRegisteredFor(IRuleAction)
00023     return [a for a in actions if 
00024                 (a.event is None or eventType.isOrExtends(a.event))]