Пример #1
0
def approvePermissions(op):
    subusersWhosPermissionsFailedToParse = []
    exceptions = []
    for subuser in op.subusers:
        if subuser.locked:
            continue
        try:
            userApproved = subuser.permissions
        except subuserlib.classes.subuser.SubuserHasNoPermissionsException:
            userApproved = None
        try:
            oldDefaults = subuser.getPermissionsTemplate()
            newDefaults = subuser.imageSource.permissions
            op.permissionsAccepter.accept(subuser=subuser,
                                          oldDefaults=oldDefaults,
                                          newDefaults=newDefaults,
                                          userApproved=userApproved)
            subuser.getPermissionsTemplate().update(
                subuser.imageSource.permissions)
            subuser.getPermissionsTemplate().save()
        except SyntaxError as e:
            subusersWhosPermissionsFailedToParse.append(subuser)
            exceptions.append(e)
        except subuserlib.classes.subuser.NoImageSourceException:
            subusersWhosPermissionsFailedToParse.append(subuser)
            user.registry.log(
                "Warning: The image source for subuser %s is no longer available."
                % subuser.name, 5)
    return (subusersWhosPermissionsFailedToParse, exceptions)
Пример #2
0
def approvePermissions(user,subuserNames,permissionsAccepter):
  subusersWhosPermissionsFailedToParse = []
  exceptions = []
  for subuserName in subuserNames:
    subuser = user.getRegistry().getSubusers()[subuserName]
    try:
      userApproved = subuser.getPermissions()
    except subuserlib.classes.subuser.SubuserHasNoPermissionsException:
      userApproved = None
    try:
      oldDefaults = subuser.getPermissionsTemplate()
      newDefaults = subuser.getImageSource().getPermissions()
      permissionsAccepter.accept(subuser=subuser,oldDefaults=oldDefaults,newDefaults=newDefaults,userApproved=userApproved)
      subuser.getPermissionsTemplate().update(subuser.getImageSource().getPermissions())
      subuser.getPermissionsTemplate().save()
    except SyntaxError as e:
      subusersWhosPermissionsFailedToParse.append(subuserName)
      exceptions.append(e)
  return (subusersWhosPermissionsFailedToParse,exceptions)
Пример #3
0
def approvePermissions(user, subuserNames, permissionsAccepter):
    subusersWhosPermissionsFailedToParse = []
    exceptions = []
    for subuserName in subuserNames:
        subuser = user.getRegistry().getSubusers()[subuserName]
        try:
            userApproved = subuser.getPermissions()
        except subuserlib.classes.subuser.SubuserHasNoPermissionsException:
            userApproved = None
        try:
            oldDefaults = subuser.getPermissionsTemplate()
            newDefaults = subuser.getImageSource().getPermissions()
            permissionsAccepter.accept(subuser=subuser,
                                       oldDefaults=oldDefaults,
                                       newDefaults=newDefaults,
                                       userApproved=userApproved)
            subuser.getPermissionsTemplate().update(
                subuser.getImageSource().getPermissions())
            subuser.getPermissionsTemplate().save()
        except SyntaxError as e:
            subusersWhosPermissionsFailedToParse.append(subuserName)
            exceptions.append(e)
    return (subusersWhosPermissionsFailedToParse, exceptions)
Пример #4
0
def approvePermissions(user,subusers,permissionsAccepter):
  subusersWhosPermissionsFailedToParse = []
  exceptions = []
  for subuser in subusers:
    if subuser.locked:
      continue
    try:
      userApproved = subuser.permissions
    except subuserlib.classes.subuser.SubuserHasNoPermissionsException:
      userApproved = None
    try:
      oldDefaults = subuser.getPermissionsTemplate()
      newDefaults = subuser.imageSource.permissions
      permissionsAccepter.accept(subuser=subuser,oldDefaults=oldDefaults,newDefaults=newDefaults,userApproved=userApproved)
      subuser.getPermissionsTemplate().update(subuser.imageSource.permissions)
      subuser.getPermissionsTemplate().save()
    except SyntaxError as e:
      subusersWhosPermissionsFailedToParse.append(subuser)
      exceptions.append(e)
    except subuserlib.classes.subuser.NoImageSourceException:
      subusersWhosPermissionsFailedToParse.append(subuser)
      user.registry.log("Warning: The image source for subuser %s is no longer available."%subuser.name,5)
  return (subusersWhosPermissionsFailedToParse,exceptions)