当前位置: 首页>>代码示例>>Python>>正文


Python IRuleAssignmentManager.items方法代码示例

本文整理汇总了Python中plone.contentrules.engine.interfaces.IRuleAssignmentManager.items方法的典型用法代码示例。如果您正苦于以下问题:Python IRuleAssignmentManager.items方法的具体用法?Python IRuleAssignmentManager.items怎么用?Python IRuleAssignmentManager.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.contentrules.engine.interfaces.IRuleAssignmentManager的用法示例。


在下文中一共展示了IRuleAssignmentManager.items方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: acquired_rules

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import items [as 别名]
    def acquired_rules(self):

        # Short circuit if this is the root of the portal
        if ISiteRoot.providedBy(self.context):
            return []

        in_use = set([r['id'] for r in self.assigned_rules()])

        storage = getUtility(IRuleStorage)
        events = self._events()

        assignments = []
        context = aq_parent(aq_inner(self.context))

        while context is not None:
            assignable = IRuleAssignmentManager(context, None)
            if assignable is not None:
                for key, assignment in assignable.items():
                    if key not in in_use and assignment.bubbles:
                        rule = storage.get(key, None)
                        if rule is not None:
                            assignments.append(dict(id=key,
                                                    title=rule.title,
                                                    description=rule.description,
                                                    trigger=events.get(rule.event, "Unknown"),
                                                    url=context.absolute_url() + '/@@manage-content-rules',
                                                    enabled=(assignment.enabled and rule.enabled), ))
            if ISiteRoot.providedBy(context):
                context = None
            else:
                context = aq_parent(context)

        return assignments
开发者ID:alecghica,项目名称:plone.app.contentrules,代码行数:35,代码来源:assignments.py

示例2: assigned_rules

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import items [as 别名]
    def assigned_rules(self):
        assignable = IRuleAssignmentManager(self.context)
        storage = getUtility(IRuleStorage)
        events = self._events()

        assignments = []
        for key, assignment in assignable.items():
            rule = storage.get(key, None)
            if rule is not None:
                assignments.append(dict(id=key,
                                        title=rule.title,
                                        description=rule.description,
                                        trigger=events.get(rule.event, "Unknown"),
                                        url=self._rule_url(key),
                                        bubbles=assignment.bubbles,
                                        enabled=assignment.enabled,
                                        global_enabled=rule.enabled, ))
        return assignments
开发者ID:alecghica,项目名称:plone.app.contentrules,代码行数:20,代码来源:assignments.py

示例3: _extractRules

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import items [as 别名]
    def _extractRules(self):
        """Extract rules to a document fragment
        """

        site = self.environ.getSite()
        storage = queryUtility(IRuleStorage)
        if storage is None:
            return
        fragment = self._doc.createDocumentFragment()

        assignment_paths = set()

        for name, rule in storage.items():
            rule_node = self._doc.createElement('rule')

            rule_node.setAttribute('name', name)
            rule_node.setAttribute('title', rule.title)
            rule_node.setAttribute('description', rule.description)
            rule_node.setAttribute('event', _getDottedName(rule.event))
            rule_node.setAttribute('enabled', str(rule.enabled))
            rule_node.setAttribute('stop-after', str(rule.stop))
            rule_node.setAttribute('cascading', str(rule.cascading))
            # Aq-wrap so that exporting fields with clever getters or
            # vocabularies will work. We also aq-wrap conditions and
            # actions below.

            rule = rule.__of__(site)

            # Add conditions
            conditions_node = self._doc.createElement('conditions')
            for condition in rule.conditions:
                condition_data = IRuleElementData(condition)
                condition = condition.__of__(rule)

                condition_node = self._doc.createElement('condition')
                condition_node.setAttribute('type', condition_data.element)

                handler = IRuleElementExportImportHandler(condition)
                handler.export_element(self._doc, condition_node)
                conditions_node.appendChild(condition_node)
            rule_node.appendChild(conditions_node)

            # Add actions
            actions_node = self._doc.createElement('actions')
            for action in rule.actions:
                action_data = IRuleElementData(action)
                action = action.__of__(rule)

                action_node = self._doc.createElement('action')
                action_node.setAttribute('type', action_data.element)

                handler = IRuleElementExportImportHandler(action)
                handler.export_element(self._doc, action_node)
                actions_node.appendChild(action_node)
            rule_node.appendChild(actions_node)

            fragment.appendChild(rule_node)
            assignment_paths.update(get_assignments(rule))
        # Export assignments last - this is necessary to ensure they
        # are orderd properly

        site_path_length = len('/'.join(site.getPhysicalPath()))
        for path in assignment_paths:
            try:
                container = site.unrestrictedTraverse(path)
            except KeyError:
                continue

            assignable = IRuleAssignmentManager(container, None)
            if assignable is None:
                continue

            location = path[site_path_length:]
            for name, assignment in assignable.items():
                assignment_node = self._doc.createElement('assignment')
                assignment_node.setAttribute('location', location)
                assignment_node.setAttribute('name', name)
                assignment_node.setAttribute('enabled', str(assignment.enabled))
                assignment_node.setAttribute('bubbles', str(assignment.bubbles))
                fragment.appendChild(assignment_node)

        return fragment
开发者ID:alecghica,项目名称:plone.app.contentrules,代码行数:84,代码来源:rules.py


注:本文中的plone.contentrules.engine.interfaces.IRuleAssignmentManager.items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。