Exemplo n.º 1
0
 def __init__(self, domroot=None):
     """
     Constructor should be called with either no parameters 
     (create blank GrantDeny), or one parameter (a DOM tree).
     
     @param domroot:     A DOM tree (default: None).
     @type  domroot:     L{webdav.WebdavResponse.Element} object
     
     @raise WebdavError: When non-valid parameters are passed a L{WebdavError} is raised.
     """
     self.grantDeny  = 0   # 0: deny, 1: grant
     self.privileges = []
     
     if domroot:
         self.grantDeny = (domroot.name == Constants.TAG_GRANT)
         for child in domroot.children:
             if child.name == Constants.TAG_PRIVILEGE and child.ns == Constants.NS_DAV:
                 self.privileges.append(Privilege(domroot=child))
             else:
                 # This shouldn't happen, someone screwed up with the params ...
                 raise WebdavError('Non-privilege tag handed to GrantDeny constructor: %s' \
                     % child.name)
     elif domroot == None:
         # no param ==> blank object
         pass
     else:
         # This shouldn't happen, someone screwed up with the params ...
         raise WebdavError('Non-valid parameters handed to GrantDeny constructor.')
Exemplo n.º 2
0
 def getCurrentUserPrivileges(self):
     """
     Returns a tuple of the current user privileges.
     
     @return: list of Privilege instances
     @rtype: list of L{Privilege<webdav.acp.Privilege.Privilege>}
     """
     privileges = self.readProperty(Constants.NS_DAV, Constants.PROP_CURRENT_USER_PRIVILEGE_SET)
     result = []
     for child in privileges.children:
         result.append(Privilege(domroot=child))
     return result
Exemplo n.º 3
0
 def addPrivilege(self, privilege):
     """
     Adds the passed privilege to list if it's not in it, yet.
     
     @param privilege: A privilege.
     @type  privilege: L{Privilege} object
     """
     inList = False
     for priv in self.privileges:
         if priv == privilege:
             inList = True
     if not inList:
         newPrivilege = Privilege()
         newPrivilege.copy(privilege)
         self.privileges.append(newPrivilege)