#NEWLINE# def __init__( self , application , ext_mgr = None ) : #NEWLINE# #INDENT# self . ext_mgr = ( ext_mgr or ExtensionManager ( get_extensions_path ( ) ) ) #NEWLINE# mapper = routes . Mapper ( ) #NEWLINE# for resource in self . ext_mgr . get_resources ( ) : #NEWLINE# #INDENT# path_prefix = resource . path_prefix #NEWLINE# if resource . parent : #NEWLINE# #INDENT# path_prefix = ( resource . path_prefix + ( '/%s/{%s_id}' % ( resource . parent [ 'collection_name' ] , resource . parent [ 'member_name' ] ) ) ) #NEWLINE# #UNINDENT# LOG . debug ( 'Extended resource: %s' , resource . collection ) #NEWLINE# for ( action , method ) in six . iteritems ( resource . collection_actions ) : #NEWLINE# #INDENT# conditions = dict ( method = [ method ] ) #NEWLINE# path = ( '/%s/%s' % ( resource . collection , action ) ) #NEWLINE# with mapper . submapper ( controller = resource . controller , action = action , path_prefix = path_prefix , conditions = conditions ) as submap : #NEWLINE# #INDENT# submap . connect ( ( path_prefix + action_controllers ) , path ) #NEWLINE# submap . connect ( ( ( path_prefix + path ) + '_format' ) , ( '%s.:(format)' % path ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ( action , method ) in resource . collection_methods . items ( ) : #NEWLINE# #INDENT# conditions = dict ( method = [ method ] ) #NEWLINE# path = ( '/%s' % resource . collection ) #NEWLINE# with mapper . submapper ( controller = resource . controller , action = action , path_prefix = path_prefix , conditions = conditions ) as submap : #NEWLINE# #INDENT# submap . connect ( ( path_prefix + path ) , path ) #NEWLINE# submap . connect ( ( ( path_prefix + path ) + '_format' ) , ( '%s.:(format)' % path ) ) #NEWLINE# #UNINDENT# #UNINDENT# mapper . resource ( resource . collection , resource . collection , controller = resource . controller , member = resource . member_actions , parent_resource = resource . parent , path_prefix = path_prefix ) #NEWLINE# #UNINDENT# action_controllers = self . _action_ext_controllers ( application , self . ext_mgr , mapper ) #NEWLINE# for action in self . ext_mgr . get_actions ( ) : #NEWLINE# #INDENT# LOG . debug ( 'Extended action: %s' , action . action_name ) #NEWLINE# controller = action_controllers [ action . collection ] #NEWLINE# controller . add_action ( action . action_name , action . handler ) #NEWLINE# #UNINDENT# req_controllers = self . _request_ext_controllers ( application , self . ext_mgr , mapper ) #NEWLINE# for request_ext in self . ext_mgr . get_request_extensions ( ) : #NEWLINE# #INDENT# LOG . debug ( 'Extended request: %s' , request_ext . key ) #NEWLINE# controller = req_controllers [ request_ext . key ] #NEWLINE# controller . add_handler ( request_ext . handler ) #NEWLINE# #UNINDENT# self . _router = routes . middleware . RoutesMiddleware ( self . _dispatch , mapper ) #NEWLINE# super ( ExtensionMiddleware , self ) . __init__ ( application )