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


Python IRuleAssignmentManager.get方法代码示例

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


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

示例1: _activate_rule

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
def _activate_rule(rule_id, context=None):
    assignable = IRuleAssignmentManager(context)
    assignment = assignable.get(rule_id, None)
    if not assignment:
        assignment = assignable[rule_id] = RuleAssignment(rule_id)
    assignment.enabled = True
    assignment.bubbles = True
    apirules.assign_rule(context, assignment.__name__)
开发者ID:bsuttor,项目名称:blog.policy,代码行数:10,代码来源:setuphandlers.py

示例2: _activate_rule

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
def _activate_rule(rule_id, context=None):
    storage = component.getUtility(IRuleStorage)
    rule = storage.get(rule_id)
    assignable = IRuleAssignmentManager(context)
    assignment = assignable.get(rule_id, None)
    if not assignment:
        assignment = assignable[rule_id] = RuleAssignment(rule_id)
    assignment.enabled = True
    assignment.bubbles = True
    get_assignments(rule).insert('/'.join(context.getPhysicalPath()))
开发者ID:collective,项目名称:collective.rcse,代码行数:12,代码来源:setuphandler.py

示例3: assignContentRulesToContainer

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
def assignContentRulesToContainer(container, storage, bubbles):
    '''Assign the standard EDRN content events to the given container.'''
    assignmentManager = IRuleAssignmentManager(container, None)
    if assignmentManager is None:
        # This container doesn't support content rules, so skip it.
        return
    for eventName in _edrnContentEvents:
        assignment = assignmentManager.get(eventName, None)
        if assignment is None:
            # Brand new assignment
            assignment = assignmentManager[eventName] = RuleAssignment(eventName)
        if not assignment.enabled:
            assignment.enabled = True
        if assignment.bubbles != bubbles:
            assignment.bubbles = bubbles
        path = '/'.join(container.getPhysicalPath())
        get_assignments(storage[eventName]).insert(path)
开发者ID:EDRN,项目名称:edrnsite.policy,代码行数:19,代码来源:setuphandlers.py

示例4: apply_rule

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
def apply_rule(folder, event):
    """ Apply content rule to execute a transition from new to pending
    """
    name = "rule-transition-registration"
    storage = getUtility(IRuleStorage)

    # Assignment
    assignable = IRuleAssignmentManager(folder, None)
    if assignable is None:
        return

    assignment = assignable.get(name, None)
    if assignment is None:
        assignment = assignable[name] = RuleAssignment(name)
    assignment.enabled = True
    assignment.bubbles = False
    path = "/".join(folder.getPhysicalPath())
    get_assignments(storage[name]).insert(path)
开发者ID:pythonbrasil,项目名称:apyb.registration,代码行数:20,代码来源:registrations.py

示例5: setup_contentrules_registration

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
def setup_contentrules_registration(registrations):
    assignable = IRuleAssignmentManager(registrations, None)
    if assignable is None:
        return None
    storage = getUtility(IRuleStorage)
    path = '/'.join(registrations.getPhysicalPath())
    names = [
        'registration-rule-transition',
        'registration-new',
        'registration-confirmed',
    ]
    for name in names:
        assignment = assignable.get(name, None)
        if assignment is None:
            assignment = assignable[name] = RuleAssignment(name)
        assignment.enabled = True
        assignment.bubbles = True

        get_assignments(storage[name]).insert(path)
开发者ID:pythonbrasil,项目名称:conference2013,代码行数:21,代码来源:setuphandlers.py

示例6: setup_contentrules_program

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
def setup_contentrules_program(program):
    assignable = IRuleAssignmentManager(program, None)
    if assignable is None:
        return None
    storage = getUtility(IRuleStorage)
    path = '/'.join(program.getPhysicalPath())
    names = [
        'talk-submited',
        'talk-accepted',
        'training-submited',
        'training-accepted',
    ]
    for name in names:
        assignment = assignable.get(name, None)
        if assignment is None:
            assignment = assignable[name] = RuleAssignment(name)
        assignment.enabled = True
        assignment.bubbles = True

        get_assignments(storage[name]).insert(path)
开发者ID:pythonbrasil,项目名称:conference2013,代码行数:22,代码来源:setuphandlers.py

示例7: _initRules

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
    def _initRules(self, node):
        """Import rules from the given node
        """

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

        for child in node.childNodes:
            if child.nodeName == 'rule':

                rule = None
                name = child.getAttribute('name')
                if name:
                    rule = storage.get(name, None)

                if rule is None:
                    rule = Rule()

                    if not name:
                        chooser = INameChooser(storage)
                        name = chooser.chooseName(None, rule)

                    storage[name] = rule
                else:
                    # Clear out conditions and actions since we're expecting new ones
                    del rule.conditions[:]
                    del rule.actions[:]

                rule.title = child.getAttribute('title')
                rule.description = child.getAttribute('description')
                event_name = child.getAttribute('event')
                rule.event = _resolveDottedName(event_name)
                if not rule.event:
                    raise ImportError("Can not import %s" % event_name)

                rule.enabled = as_bool(child.getAttribute('enabled'), True)
                rule.stop = as_bool(child.getAttribute('stop-after'))

                # Aq-wrap to enable complex setters for elements below
                # to work

                rule = rule.__of__(site)

                for rule_config_node in child.childNodes:
                    if rule_config_node.nodeName == 'conditions':
                        for condition_node in rule_config_node.childNodes:
                            if not condition_node.nodeName == 'condition':
                                continue

                            type_ = condition_node.getAttribute('type')
                            element_type = getUtility(IRuleCondition, name=type_)
                            if element_type.factory is None:
                                continue

                            condition = element_type.factory()

                            # Aq-wrap in case of complex setters
                            condition = condition.__of__(rule)

                            handler = IRuleElementExportImportHandler(condition)
                            handler.import_element(condition_node)

                            rule.conditions.append(aq_base(condition))

                    elif rule_config_node.nodeName == 'actions':
                        for action_node in rule_config_node.childNodes:
                            if not action_node.nodeName == 'action':
                                continue

                            type_ = action_node.getAttribute('type')
                            element_type = getUtility(IRuleAction, name=type_)
                            if element_type.factory is None:
                                continue

                            action = element_type.factory()

                            # Aq-wrap in case of complex setters
                            action = action.__of__(rule)

                            handler = IRuleElementExportImportHandler(action)
                            handler.import_element(action_node)

                            rule.actions.append(aq_base(action))

            elif child.nodeName == 'assignment':
                location = child.getAttribute('location')
                if location.startswith("/"):
                    location = location[1:]

                try:
                    container = site.unrestrictedTraverse(str(location))
                except KeyError:
                    continue

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

#.........这里部分代码省略.........
开发者ID:afrepues,项目名称:plone.app.contentrules,代码行数:103,代码来源:rules.py

示例8: __call__

# 需要导入模块: from plone.contentrules.engine.interfaces import IRuleAssignmentManager [as 别名]
# 或者: from plone.contentrules.engine.interfaces.IRuleAssignmentManager import get [as 别名]
    def __call__(self):
        context = aq_inner(self.context)
        request = aq_inner(self.request)
        form = request.form
        path = '/'.join(context.getPhysicalPath())
        status = IStatusMessage(self.request)
        assignable = IRuleAssignmentManager(context)
        storage = getUtility(IRuleStorage)

        operation = request.get('operation', None)

        if operation == 'move_up':
            rule_id = request.get('rule_id')
            keys = list(assignable.keys())
            idx = keys.index(rule_id)
            del keys[idx]
            keys.insert(idx-1, rule_id)
            assignable.updateOrder(keys)
        elif operation == 'move_down':
            rule_id = request.get('rule_id')
            keys = list(assignable.keys())
            idx = keys.index(rule_id)
            del keys[idx]
            keys.insert(idx+1, rule_id)
            assignable.updateOrder(keys)
        elif 'form.button.AddAssignment' in form:
            rule_id = form.get('rule_id')
            assignable[rule_id] = RuleAssignment(rule_id)
            get_assignments(storage[rule_id]).insert(path)
        elif 'form.button.Delete' in form:
            rule_ids = form.get('rule_ids', ())
            for r in rule_ids:
                del assignable[r]
                get_assignments(storage[r]).remove(path)
            status.addStatusMessage(_(u"Assignments deleted."), type='info')
        elif 'form.button.Enable' in form:
            rule_ids = form.get('rule_ids', ())
            for r in rule_ids:
                assignment = assignable.get(r, None)
                if assignment is not None:
                    assignment.enabled = True
            status.addStatusMessage(_(u"Assignments enabled."), type='info')
        elif 'form.button.Disable' in form:
            rule_ids = form.get('rule_ids', ())
            for r in rule_ids:
                assignment = assignable.get(r, None)
                if assignment is not None:
                    assignment.enabled = False
            status.addStatusMessage(_(u"Assignments disabled."), type='info')
        elif 'form.button.Bubble' in form:
            rule_ids = form.get('rule_ids', ())
            for r in rule_ids:
                assignment = assignable.get(r, None)
                if assignment is not None:
                    assignment.bubbles = True
            status.addStatusMessage(_(u"Changes saved."), type='info')
        elif 'form.button.NoBubble' in form:
            rule_ids = form.get('rule_ids', ())
            for r in rule_ids:
                assignment = assignable.get(r, None)
                if assignment is not None:
                    assignment.bubbles = False
            status.addStatusMessage(_(u"Changes saved."), type='info')

        return self.template()
开发者ID:afrepues,项目名称:plone.app.contentrules,代码行数:67,代码来源:assignments.py


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