#NEWLINE# def as_int( self , perm ) : #NEWLINE# #INDENT# "\n        A utility method to convert several types of arguments into the integer representation.\n        \n        Converts strings by looking up the name\n        Converts a list or tuple by OR'ing the int value for each item\n        " #NEWLINE# if isinstance ( perm , int ) : #NEWLINE# #INDENT# valid_perm = self #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( perm , basestring ) : #NEWLINE# #INDENT# valid_perm = getattr ( self , perm ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( perm , ( list , tuple ) ) : #NEWLINE# #INDENT# valid_perm = 0 #NEWLINE# for item in perm : #NEWLINE# #INDENT# valid_perm |= self . as_int ( item ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise UnknownPermission ( ( "'%s' is an unknown permission type." % perm ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return valid_perm