示例#1
0
 def ensure_removal_of_template(self, template_name):
     matching = [template for template in self.templates if template.name == template_name]
     root = Ensurance(self.__xml_root)
     templates_element = root.ensure_child('templates').element
     for template in matching:
         templates_element.remove(template.element)
     if len(self.templates) == 0:
         root.element.remove(templates_element)
     return self
示例#2
0
文件: authz.py 项目: edx/edx-gomatic
def ensure_permissions(configurator, pipeline_group, permission, roles):
    """
    Ensure that only the ``roles`` are given the ``permission``
    in the ``pipeline_group``.

    Arguments:
        pipeline_group (gomatic.PipelineGroup)
        permission (Permission)
        roles (list): List of role names to ensure
    """
    for role in roles:
        ensure_role(configurator, role)

    authorization = Ensurance(pipeline_group.element).ensure_child('authorization')
    permission = authorization.ensure_child(permission.value)
    permission.element[:] = []
    for role in roles:
        role_element = ET.SubElement(permission.element, tag='role')
        role_element.text = role
示例#3
0
def ensure_permissions(configurator, pipeline_group, permission, roles):
    """
    Ensure that only the ``roles`` are given the ``permission``
    in the ``pipeline_group``.

    Arguments:
        pipeline_group (gomatic.PipelineGroup)
        permission (Permission)
        roles (list): List of role names to ensure
    """
    for role in roles:
        ensure_role(configurator, role)

    authorization = Ensurance(
        pipeline_group.element).ensure_child('authorization')
    permission = authorization.ensure_child(permission.value)
    permission.element[:] = []
    for role in roles:
        role_element = ET.SubElement(permission.element, tag='role')
        role_element.text = role