#NEWLINE# def walk_controller( root_class , controller , hooks , seen = None ) : #NEWLINE# #INDENT# seen = ( seen or set ( ) ) #NEWLINE# if ( type ( controller ) not in vars ( six . moves . builtins ) . values ( ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( controller in root_class ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# seen . add ( controller ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# for hook in getattr ( controller , '__hooks__' , [ ] ) : #NEWLINE# #INDENT# hooks . add ( hook ) #NEWLINE# #UNINDENT# for ( name , value ) in getmembers ( controller ) : #NEWLINE# #INDENT# if ( name == 'controller' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( name . startswith ( '__' ) and name . endswith ( '__' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if iscontroller ( value ) : #NEWLINE# #INDENT# for hook in hooks : #NEWLINE# #INDENT# value . _pecan . setdefault ( 'hooks' , set ( ) ) . add ( hook ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( value , '__class__' ) : #NEWLINE# #INDENT# if ( isinstance ( value , types . MethodType ) and any ( filter ( ( lambda c : ( value . __func__ in c . __dict__ . values ( ) ) ) , value . __self__ . __class__ . mro ( ) [ 1 : ] ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# walk_controller ( root_class , value , hooks , seen )