#NEWLINE# def authentication_requirement( self , target , permission ) : #NEWLINE# #INDENT# "Check the target to see if it or any of its 'parents' require authentication." #NEWLINE# if isinstance ( target , tuple ) : #NEWLINE# #INDENT# req = getattr ( target [ 1 ] , 'authentication_required' , None ) #NEWLINE# if ( req is False ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( req is not None ) : #NEWLINE# #INDENT# return target [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . authentication_requirement ( target [ 0 ] , 'write' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( permission in getattr ( target , 'authentication_required' , [ ] ) ) : #NEWLINE# #INDENT# return target #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( target , Document ) : #NEWLINE# #INDENT# return self . authentication_requirement ( target . collection , permission ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( target , Collection ) : #NEWLINE# #INDENT# return self . authentication_requirement ( target . application , permission ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( target , Application ) : #NEWLINE# #INDENT# return self . authentication_requirement ( target . suite , permission ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None