#NEWLINE# def requireAccess( self , doc , user = None , level = AccessType . READ ) : #NEWLINE# #INDENT# '\n        This wrapper just provides a standard way of throwing an\n        access denied exception if the access check fails.\n        ' #NEWLINE# if ( not self . hasAccess ( doc , user , level ) ) : #NEWLINE# #INDENT# if ( level == AccessType . READ ) : #NEWLINE# #INDENT# perm = 'Read' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( level == AccessType . WRITE ) : #NEWLINE# #INDENT# perm = 'Write' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( level in ( AccessType . ADMIN , AccessType . SITE_ADMIN ) ) : #NEWLINE# #INDENT# perm = 'Admin' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# perm = 'Unknown level' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if user : #NEWLINE# #INDENT# userid = str ( user . get ( '_id' , '' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# userid = None #NEWLINE# #UNINDENT# raise AccessException ( ( '%s access denied for %s %s (user %s).' % ( level , self . name , doc . get ( '_id' , 'unknown' ) , userid ) ) )