def __init__(self, connection, database_path, public_store, queue_store, staticdirector, user_template_path=None): # Get the template environment self.template_env = util.get_jinja_env(user_template_path) # Set up storage systems self.public_store = public_store self.queue_store = queue_store # Set up database self.connection = connection self.db = connection[database_path] models.register_models(connection) # set up routing self.routing = routing.get_mapper() # set up staticdirector tool self.staticdirector = staticdirector # certain properties need to be accessed globally eg from # validators, etc, which might not access to the request # object. setup_globals(db_connection=connection, database=self.db, public_store=self.public_store, queue_store=self.queue_store)
def __init__(self, connection, database_path, public_store, queue_store, staticdirector, user_template_path=None): # Get the template environment self.template_env = util.get_jinja_env(user_template_path) # Set up storage systems self.public_store = public_store self.queue_store = queue_store # Set up database self.connection = connection self.db = connection[database_path] models.register_models(connection) # set up routing self.routing = routing.get_mapper() # set up staticdirector tool self.staticdirector = staticdirector # certain properties need to be accessed globally eg from # validators, etc, which might not access to the request # object. setup_globals( db_connection=connection, database=self.db, public_store=self.public_store, queue_store=self.queue_store)
def setup_self(setup_globals_func=setup_globals): """ Transform this module into a celery config module by reading the mediagoblin config file. Set the environment variable MEDIAGOBLIN_CONFIG to specify where this config file is at and what section it uses. By default it defaults to 'mediagoblin.ini:app:mediagoblin'. The first colon ":" is a delimiter between the filename and the config section, so in this case the filename is 'mediagoblin.ini' and the section where mediagoblin is defined is 'app:mediagoblin'. Args: - 'setup_globals_func': this is for testing purposes only. Don't set this! """ mgoblin_conf_file, mgoblin_section = os.environ.get( 'MEDIAGOBLIN_CONFIG', 'mediagoblin.ini:app:mediagoblin').split(':', 1) if not os.path.exists(mgoblin_conf_file): raise IOError("MEDIAGOBLIN_CONFIG not set or file does not exist") parser = NicerConfigParser(mgoblin_conf_file) parser.read(mgoblin_conf_file) parser._defaults.setdefault( 'here', os.path.dirname(os.path.abspath(mgoblin_conf_file))) parser._defaults.setdefault('__file__', os.path.abspath(mgoblin_conf_file)) mgoblin_section = dict(parser.items(mgoblin_section)) mgoblin_conf = dict([(section_name, dict(parser.items(section_name))) for section_name in parser.sections()]) setup_celery_from_config(mgoblin_section, mgoblin_conf, settings_module=OUR_MODULENAME, set_environ=False) connection = mongokit.Connection(mgoblin_section.get('db_host'), mgoblin_section.get('db_port')) db = connection[mgoblin_section.get('db_name', 'mediagoblin')] models.register_models(connection) # Set up the storage systems. public_store = storage.storage_system_from_paste_config( mgoblin_section, 'publicstore') queue_store = storage.storage_system_from_paste_config( mgoblin_section, 'queuestore') setup_globals_func(db_connection=connection, database=db, public_store=public_store, queue_store=queue_store)
def setup_self(setup_globals_func=setup_globals): """ Transform this module into a celery config module by reading the mediagoblin config file. Set the environment variable MEDIAGOBLIN_CONFIG to specify where this config file is at and what section it uses. By default it defaults to 'mediagoblin.ini:app:mediagoblin'. The first colon ":" is a delimiter between the filename and the config section, so in this case the filename is 'mediagoblin.ini' and the section where mediagoblin is defined is 'app:mediagoblin'. Args: - 'setup_globals_func': this is for testing purposes only. Don't set this! """ mgoblin_conf_file, mgoblin_section = os.environ.get("MEDIAGOBLIN_CONFIG", "mediagoblin.ini:app:mediagoblin").split( ":", 1 ) if not os.path.exists(mgoblin_conf_file): raise IOError("MEDIAGOBLIN_CONFIG not set or file does not exist") parser = NicerConfigParser(mgoblin_conf_file) parser.read(mgoblin_conf_file) parser._defaults.setdefault("here", os.path.dirname(os.path.abspath(mgoblin_conf_file))) parser._defaults.setdefault("__file__", os.path.abspath(mgoblin_conf_file)) mgoblin_section = dict(parser.items(mgoblin_section)) mgoblin_conf = dict([(section_name, dict(parser.items(section_name))) for section_name in parser.sections()]) setup_celery_from_config(mgoblin_section, mgoblin_conf, settings_module=OUR_MODULENAME, set_environ=False) connection = mongokit.Connection(mgoblin_section.get("db_host"), mgoblin_section.get("db_port")) db = connection[mgoblin_section.get("db_name", "mediagoblin")] models.register_models(connection) # Set up the storage systems. public_store = storage.storage_system_from_paste_config(mgoblin_section, "publicstore") queue_store = storage.storage_system_from_paste_config(mgoblin_section, "queuestore") setup_globals_func(db_connection=connection, database=db, public_store=public_store, queue_store=queue_store)