本文整理汇总了Python中plone.contentrules.engine.interfaces.IRuleAssignmentManager.getRules方法的典型用法代码示例。如果您正苦于以下问题:Python IRuleAssignmentManager.getRules方法的具体用法?Python IRuleAssignmentManager.getRules怎么用?Python IRuleAssignmentManager.getRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.contentrules.engine.interfaces.IRuleAssignmentManager
的用法示例。
在下文中一共展示了IRuleAssignmentManager.getRules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import getRules [as 别名]
def __call__(self, event, bubbled=False, rule_filter=None):
assignments = IRuleAssignmentManager(self.context)
for rule in assignments.getRules(event, bubbled=bubbled):
# for each rule assigned in this context - bubbled means rule apply on subfolders
if rule_filter is None or rule_filter(self.context, rule, event) == True:
# execute the rule if it is not filtered, for exemple,
# it has not been executed on the same content but from an other context
# in the same request
# we store cascading option in the filter. if true, this will allow
# rules to be executed because of the actions ran by this rule.
if rule_filter is not None:
cascade_before = getattr(rule_filter, 'cascade', False)
rule_filter.cascade = rule.cascading
executable = getMultiAdapter((self.context, rule, event), IExecutable)
executable()
if rule_filter is not None:
rule_filter.cascade = cascade_before
if rule.stop:
# stop rule execution if 'Stop rules after' option has been selected
raise StopRule(rule)