#NEWLINE# def configure( self , runtime_environment ) : #NEWLINE# #INDENT# self . runtime_environment = runtime_environment #NEWLINE# self . dependency_manager = runtime_environment . dependency_manager #NEWLINE# self . resource_manager = runtime_environment . resource_manager #NEWLINE# cm = runtime_environment . configuration_manager #NEWLINE# for ( name , config ) in cm . get ( self . configuration_key , dict ( ) ) . items ( ) : #NEWLINE# #INDENT# if ( not config . get ( 'enabled' , True ) ) : #NEWLINE# #INDENT# logger . info ( 'Not starting cyclone site [{0}] because it is disabled.' . format ( name ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# config = copy . deepcopy ( config ) #NEWLINE# listen = str ( config . pop ( 'listen' , '8888' ) ) #NEWLINE# application_factory_name = config . pop ( 'application_factory' , 'cyclone.web.Application' ) #NEWLINE# application_factory = reflect . namedAny ( application_factory_name ) #NEWLINE# application_config = config . pop ( 'application' , dict ( ) ) #NEWLINE# handlers = application_config . pop ( 'handlers' , [ ] ) #NEWLINE# transforms = self . _resolve_transforms ( application_config . pop ( 'transforms' , list ( ) ) ) #NEWLINE# if ( 'ui_modules' in application_config ) : #NEWLINE# #INDENT# ui_modules = application_config [ 'ui_modules' ] #NEWLINE# if isinstance ( ui_modules , dict ) : #NEWLINE# #INDENT# for ( key , value ) in ui_modules . items ( ) : #NEWLINE# #INDENT# ui_modules [ key ] = reflect . namedAny ( value ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( ui_modules , basestring ) : #NEWLINE# #INDENT# application_config [ 'ui_modules' ] = reflect . namedAny ( ui_modules ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Unknown ui_modules type: {0}' . format ( type ( ui_modules ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for ( key , value ) in application_config . items ( ) : #NEWLINE# #INDENT# if ( key . endswith ( '_path' ) and isinstance ( value , filepath . FilePath ) ) : #NEWLINE# #INDENT# application_config [ key ] = value . path #NEWLINE# #UNINDENT# #UNINDENT# for ( i , handler ) in enumerate ( handlers ) : #NEWLINE# #INDENT# handlers [ i ] = self . _resolve_urlspec ( name , handler ) #NEWLINE# #UNINDENT# if ( 'piped_dependencies' in application_config ) : #NEWLINE# #INDENT# for ( key , value ) in application_config [ 'piped_dependencies' ] . items ( ) : #NEWLINE# #INDENT# application_config [ 'piped_dependencies' ] [ key ] = ( dict ( provider = value ) if isinstance ( value , basestring ) else value ) #NEWLINE# #UNINDENT# application_config [ 'piped_dependencies' ] = self . dependency_manager . create_dependency_map ( self , ** application_config [ 'piped_dependencies' ] ) #NEWLINE# #UNINDENT# application = application_factory ( handlers , transforms = transforms , ** application_config ) #NEWLINE# service = strports . service ( listen , application ) #NEWLINE# service . setServiceParent ( runtime_environment . application ) #NEWLINE# self . _applications_by_name [ name ] = application #NEWLINE# self . resource_manager . register ( 'cyclone.application.{0}' . format ( name ) , provider = self )