#NEWLINE# def configure( factory = None , **kwargs ) : #NEWLINE# #INDENT# if ( not factory ) : #NEWLINE# #INDENT# factory = os . environ . get ( ENVIRONMENT_VARIABLE ) #NEWLINE# if ( not factory ) : #NEWLINE# #INDENT# raise ImportError ( ( 'Settings could not be imported because configure was called without arguments and the environment variable %s is undefined.' % ENVIRONMENT_VARIABLE ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( '.' in factory ) : #NEWLINE# #INDENT# ( factory_module , factory_name ) = factory . rsplit ( '.' , 1 ) #NEWLINE# try : #NEWLINE# #INDENT# mod = import_module ( factory_module ) #NEWLINE# factory_obj = getattr ( mod , factory_name ) #NEWLINE# #UNINDENT# except ( ImportError , AttributeError ) as err : #NEWLINE# #INDENT# raise SettingsFactoryDoesNotExist ( ( 'The object "%s" could not be found (Is it on sys.path?): %s' % ( factory , err ) ) ) #NEWLINE# #UNINDENT# settings_obj = factory_obj ( ) #NEWLINE# settings_dict = dict ( ( ( k , getattr ( settings_obj , k ) ) for k in dir ( settings_obj ) if ( not str ( k ) . startswith ( '_' ) ) ) ) #NEWLINE# if ( 'SETTINGS_MODULE' not in kwargs ) : #NEWLINE# #INDENT# settings_dict [ 'SETTINGS_MODULE' ] = ( '%s_%s_unrolledcbsettings' % ( factory_module , factory_name ) ) #NEWLINE# #UNINDENT# sys . meta_path . insert ( 0 , SettingsImporter ( settings_dict [ 'SETTINGS_MODULE' ] , settings_dict ) ) #NEWLINE# os . environ [ DJANGO_SETTINGS_MODULE ] = settings_dict [ 'SETTINGS_MODULE' ] #NEWLINE# return ( mod , settings_obj ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise InvalidSettingsFactory ( ( '%s is not a valid settings factory. Please provide something of the form `path.to.MySettingsFactory`' % factory ) )