예제 #1
0
 def addGrantDeny(self, grantDeny):
     '''
     Adds the passed GrantDeny object to list if it's not in it, yet.
     
     @param grantDeny: A grant or deny clause.
     @type  grantDeny: L{GrantDeny} object
     '''
     # only add it if it's not in the list, yet ...
     inList = 0
     for element in self.grantDenies:
         if element == grantDeny:
             inList = 1
     if not inList:
         newGrantDeny = GrantDeny()
         newGrantDeny.copy(grantDeny)
         self.grantDenies.append(newGrantDeny)
예제 #2
0
 def addGrantDeny(self, grantDeny):
     '''
     Adds the passed GrantDeny object to list if it's not in it, yet.
     
     @param grantDeny: A grant or deny clause.
     @type  grantDeny: L{GrantDeny} object
     '''
     # only add it if it's not in the list, yet ...
     inList = 0
     for element in self.grantDenies:
         if element == grantDeny:
             inList = 1
     if not inList:
         newGrantDeny = GrantDeny()
         newGrantDeny.copy(grantDeny)
         self.grantDenies.append(newGrantDeny)
예제 #3
0
    def __init__(self, domroot=None, principal=None, grantDenies=None):
        """
        Constructor should be called with either no parameters (create blank ACE),
        one parameter (a DOM tree or principal), or two parameters (principal and 
        sequence of GrantDenies).
        
        @param domroot:     A DOM tree (default: None).
        @type  domroot:     L{webdav.WebdavResponse.Element} object
        @param principal:   A principal (user or group), (default: None).
        @type  principal:   L{Principal} object
        @param grantDenies: Grant and deny clauses for privileges (default: None).
        @type  grantDenies: sequence of L{GrantDeny} objects
        
        @raise WebdavError: When non-valid parameters are passed a L{WebdavError} is raised.
        """
        self.principal = Principal()
        self.protected = None
        self.inherited = None
        self.invert = None
        self.grantDenies = []

        if domroot:
            self.principal = Principal(domroot=domroot.find(
                Constants.TAG_PRINCIPAL, Constants.NS_DAV))
            self.inherited = domroot.find(Constants.TAG_INHERITED,
                                          Constants.NS_DAV)
            if self.inherited:
                self.inherited = self.inherited.children[0].textof()
            if domroot.find(Constants.TAG_PROTECTED, Constants.NS_DAV):
                self.protected = 1
            for child in domroot.children:
                if child.ns == Constants.NS_DAV \
                        and (child.name == Constants.TAG_GRANT or child.name == Constants.TAG_DENY):
                    self.grantDenies.append(GrantDeny(domroot=child))
        elif isinstance(principal, Principal):
            newPrincipal = Principal()
            newPrincipal.copy(principal)
            self.principal = newPrincipal
            if (isinstance(grantDenies, list)
                    or isinstance(grantDenies, tuple)):
                self.addGrantDenies(grantDenies)
        elif domroot == None and grantDenies == None:
            # no param ==> blank ACE
            pass
        else:
            # This shouldn't happen, someone screwed up with the params ...
            raise WebdavError('non-valid parameters handed to ACE constructor')