def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='prickle', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = prickle.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Jinja2 Environment jinja2_env = Environment(loader=FileSystemLoader(paths['templates'])) config['pylons.app_globals'].jinja2_env = jinja2_env # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='blog', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = blog.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Jinja2 Environment config['pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader( [FileSystemLoader(path) for path in paths['templates']])) # Jinja2's unable to request c's attributes without strict_c config['pylons.strict_tmpl_context'] = True # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='toast', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = toast.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Jinja2 Environment jinja2_env = Environment(loader=FileSystemLoader(paths['templates'])) config['pylons.app_globals'].jinja2_env = jinja2_env # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['toast.application'], config['toast.database'] = build_application() return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, 'controllers'), static_files=[app_conf['static_path'], os.path.join(root, 'public')], templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='inphosite', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = inphosite.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['unicode'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='sssweb', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = sssweb.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object""" config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, "controllers"), static_files=os.path.join(root, "public"), templates=[os.path.join(root, "templates")]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package="harstorage", paths=paths) config["routes.map"] = make_map(config) config["pylons.app_globals"] = app_globals.Globals(config) config["pylons.h"] = harstorage.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config["pylons.app_globals"].cache) # Create the Mako TemplateLookup, with the default auto-escaping config["pylons.app_globals"].mako_lookup = TemplateLookup( directories=paths["templates"], error_handler=handle_mako_error, module_directory=os.path.join(app_conf["cache_dir"], "templates"), input_encoding="utf-8", default_filters=["escape"], imports=["from webhelpers.html import escape"]) return config
def load_environment(global_conf, app_conf): 'Configure the Pylons environment via the ``pylons.config`` object' # Set paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config = PylonsConfig() config.init_app(global_conf, app_conf, package='georegistry', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # Return return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment for SIS.""" config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='sis', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = sis.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( paths['templates'], auto_reload=True) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf, with_db=True): """Configure the Pylons environment via the ``pylons.config`` object """ # Pylons paths conf_copy = global_conf.copy() conf_copy.update(app_conf) site_templates = create_site_subdirectory('templates', app_conf=conf_copy) root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) client_containing = app_conf.get('adhocracy.client_location') if client_containing: client_root = os.path.join(client_containing, 'adhocracy_client') sys.path.insert(0, client_containing) import adhocracy_client.static sys.modules['adhocracy.static'] = adhocracy_client.static else: client_root = root import adhocracy.static paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(client_root, 'static'), templates=[site_templates, os.path.join(client_root, 'templates')]) # Initialize config with the basic options config = PylonsConfig() config.init_app(global_conf, app_conf, package='adhocracy', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = adhocracy.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from markupsafe import escape']) config['pylons.strict_tmpl_context'] = False # Setup the SQLAlchemy database engine engineOpts = {} if asbool(config.get('adhocracy.debug.sql', False)): engineOpts['connectionproxy'] = TimerProxy() engine = engine_from_config(config, 'sqlalchemy.', **engineOpts) init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) init_site(config) if with_db: init_search() init_democracy() RQConfig.setup_from_config(config) return config
def load_environment(global_conf, app_conf): 'Configure the Pylons environment via the ``pylons.config`` object' # Set paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config = PylonsConfig() config.init_app(global_conf, app_conf, package='jobitos', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # Return return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='agent', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) pylons.config.update(config) # create the base directory for the agent path = os.path.join(config['agent_root'], 'service_nodes') if not os.path.exists(path): os.makedirs(path) path = os.path.join(config['agent_root'], 'packages') if not os.path.exists(path): os.makedirs(path) # create directories for distribution client # If repo_root is not specified, assume it is same as agent_root if config['repo_root'] is None or config['repo_root'] == '': config['repo_root'] = config['agent_root'] path = config['repo_root'] if not os.path.exists(path): os.makedirs(path) # start the agent globals startAgentGlobals() return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # import our private.ini that holds keys, etc imp = global_conf.get('import') if imp: cp = ConfigParser() cp.read(imp) global_conf.update(cp.defaults()) if cp.has_section('APP'): app_conf.update(cp.items('APP')) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='linkdrop', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) import linkdrop.lib.helpers as h config['pylons.h'] = h # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # sqlalchemy auto migration if asbool(config.get('migrate.auto')): try: # managed upgrades cschema = schema.ControlledSchema.create(engine, config['migrate.repository']) cschema.update_db_from_model(meta.Base.metadata) except exceptions.InvalidRepositoryError, e: # unmanaged upgrades diff = schemadiff.getDiffOfModelAgainstDatabase( meta.Base.metadata, engine, excludeTables=None) genmodel.ModelGenerator(diff).applyModel()
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='agent', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) pylons.config.update(config) # create the base directory for the agent path = os.path.join(config['agent_root'], 'service_nodes') if not os.path.exists(path): os.makedirs(path) path = os.path.join(config['agent_root'], 'packages') if not os.path.exists(path): os.makedirs(path) # create directories for distribution client # If repo_root is not specified, assume it is same as agent_root if config['repo_root'] is None or config['repo_root'] == '': config['repo_root'] = config['agent_root'] path = config['repo_root'] if not os.path.exists(path): os.makedirs(path) # start the agent globals startAgentGlobals() return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # setup themes template_paths = [os.path.join(root, 'templates')] themesbase = app_conf.get('baruwa.themes.base', None) if themesbase and os.path.isabs(themesbase): templatedir = os.path.join(themesbase, 'templates') if os.path.isdir(templatedir): template_paths.append(templatedir) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=template_paths) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='baruwa', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = baruwa.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine surl = config['sqlalchemy.url'] if surl.startswith('mysql'): conv = conversions.copy() conv[246] = float engine = create_engine(surl, pool_recycle=1800, connect_args=dict(conv=conv)) else: engine = engine_from_config(config, 'sqlalchemy.', poolclass=NullPool) init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment( global_conf, app_conf ): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app( global_conf, app_conf, package='sparta', paths=paths ) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config["pylons.strict_tmpl_context"] = False # 중요한 셋업, 젠씨에서 ContextOBJ에 데이터가 없을때 공백으로 대체시킴 # Setup cache object as early as possible import pylons pylons.cache._push_object( config['pylons.app_globals'].cache ) # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( paths['templates'], auto_reload=True ) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model( engine ) # CONFIGURATION OPTIONS HERE (note: all config options will override any Pylons config options) #try: preCachingTables() # 테이블 캐슁 #except Exception as err: # print err # 아키텍쳐 셋팅 init_architect() # DB에 저장된 설정정보 가져옴 try: init_configset() except Exception as err: pass #print err #try: plugins.init_plugins() # 플러그인 셋팅 #except Exception as err: # print err log.debug("DONE: load_environment ") return config
def load_environment(global_conf, app_conf, initial=False): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = rhodecode.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) #sets the c attribute access when don't existing attribute are accessed config['pylons.strict_tmpl_context'] = True test = os.path.split(config['__file__'])[-1] == 'test.ini' if test: from rhodecode.lib.utils import create_test_env, create_test_index from rhodecode.tests import TESTS_TMP_PATH create_test_env(TESTS_TMP_PATH, config) create_test_index(TESTS_TMP_PATH, config, True) #MULTIPLE DB configs # Setup the SQLAlchemy database engine sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') init_model(sa_engine_db1) repos_path = make_ui('db').configitems('paths')[0][1] repo2db_mapper(ScmModel().repo_scan(repos_path)) set_available_permissions(config) config['base_path'] = repos_path set_rhodecode_config(config) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='tedx', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = tedx.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) def my_preprocessor(text): text = re.sub(r'<(/?)mako:', r"<\1%", text) ## return text # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape'], preprocessor=my_preprocessor) config['pylons.strict_tmpl_context'] = False # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) #MIMETypes for video #MIMETypes.init() #MIMETypes.add_alias('mp4', 'video/mpeg') #MIMETypes.add_alias('flv', 'video/x-flv') return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # setup themes template_paths = [os.path.join(root, 'templates')] themesbase = app_conf.get('baruwa.themes.base', None) if themesbase and os.path.isabs(themesbase): templatedir = os.path.join(themesbase, 'templates') if os.path.isdir(templatedir): template_paths.append(templatedir) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=template_paths) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='baruwa', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = baruwa.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine surl = config['sqlalchemy.url'] if surl.startswith('mysql'): conv = conversions.copy() conv[246] = float engine = create_engine(surl, pool_recycle=1800, connect_args=dict(conv=conv)) else: engine = engine_from_config(config, 'sqlalchemy.', poolclass=NullPool) init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='converter.web', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = converter.web.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # Configure logging from input paster config file. This is # normally configured by paster serve but we do not use it. _configureLogging(global_conf['__file__']) log.info('Creating server instance.') if config['converter.start_server'] == 'true': s = server.CreateServer(config) config['converter._server'] = s config['converter.client'] = Client(s) s.Start() return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='desio', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = desio.lib.helpers config['pylons.strict_tmpl_context'] = False config['beaker.session.cookie_expires'] = None # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine config['pylons.app_globals'].sa_default_engine = engine_from_config( config, 'sqlalchemy.default.', proxy=TimerProxy()) init_model(config['pylons.app_globals'].sa_default_engine) config['pylons.errorware']['smtp_username'] = config.get('smtp_username') config['pylons.errorware']['smtp_password'] = config.get('smtp_password') config['pylons.errorware']['smtp_use_tls'] = config.get('smtp_use_tls') config['pylons.errorware']['smtp_port'] = config.get('smtp_port') # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) fs.setup_directories(config) setup_turbomail(config) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object""" config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, "controllers"), static_files=os.path.join(root, "public"), templates=[os.path.join(root, "templates")], ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package="ocsmanager", paths=paths) config["routes.map"] = make_map(config) config["pylons.app_globals"] = app_globals.Globals(config) config["pylons.h"] = ocsmanager.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config["pylons.app_globals"].cache) # Create the Mako TemplateLookup, with the default auto-escaping config["pylons.app_globals"].mako_lookup = TemplateLookup( directories=paths["templates"], error_handler=handle_mako_error, module_directory=os.path.join(app_conf["cache_dir"], "templates"), input_encoding="utf-8", default_filters=["escape"], imports=["from webhelpers.html import escape"], ) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) ocsconfig = OCSConfig.OCSConfig(global_conf["__file__"]) config["ocsmanager"] = ocsconfig.load() config["samba"] = _load_samba_environment() config["ocdb"] = get_openchangedb(config["samba"]["samdb_ldb"].lp) mapistore.set_mapping_path(config["ocsmanager"]["main"]["mapistore_data"]) mstore = mapistore.MAPIStore(config["ocsmanager"]["main"]["mapistore_root"]) config["mapistore"] = mstore config["management"] = mstore.management() if config["ocsmanager"]["main"]["debug"] == "yes": config["management"].verbose = True return config
def load_environment(global_conf, app_conf): """ Configures the Pylons environment via the ``pylons.config`` object. ``global_conf`` Global configuration. ``app_conf`` Application configuration. """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='debexpo', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = debexpo.lib.helpers import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) #config['pylons.strict_c'] = False #config['pylons.tmpl_context_attach_args'] = True # Customize templating options via this variable config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=[ 'from webhelpers.html import escape', 'from debexpo.lib.filters import semitrusted' ]) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='desio', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = desio.lib.helpers config['pylons.strict_tmpl_context'] = False config['beaker.session.cookie_expires'] = None # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine config['pylons.app_globals'].sa_default_engine = engine_from_config(config, 'sqlalchemy.default.', proxy=TimerProxy()) init_model(config['pylons.app_globals'].sa_default_engine) config['pylons.errorware']['smtp_username'] = config.get('smtp_username') config['pylons.errorware']['smtp_password'] = config.get('smtp_password') config['pylons.errorware']['smtp_use_tls'] = config.get('smtp_use_tls') config['pylons.errorware']['smtp_port'] = config.get('smtp_port') # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) fs.setup_directories(config) setup_turbomail(config) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='project', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = project.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from markupsafe import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # Import the jinja components we need from jinja2 import ChoiceLoader, Environment, FileSystemLoader # Create the Jinja Environment config['pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader( [FileSystemLoader(path) for path in paths['templates']])) # Jinja's unable to request c's attributes without strict_c config['pylons.strict_c'] = True # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='converter.web', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = converter.web.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # Configure logging from input paster config file. This is # normally configured by paster serve but we do not use it. _configureLogging(global_conf['__file__']) log.info('Creating server instance.') if config['converter.start_server'] == 'true': s = server.CreateServer(config) config['converter._server'] = s config['converter.client'] = Client(s) s.Start() return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='ocsmanager', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = ocsmanager.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) ocsconfig = OCSConfig.OCSConfig(global_conf['__file__']) config['ocsmanager'] = ocsconfig.load() config['samba'] = _load_samba_environment() config['oc_ldb'] = _load_ocdb() mapistore.set_mapping_path(config['ocsmanager']['main']['mapistore_data']) mstore = mapistore.MAPIStore(config['ocsmanager']['main']['mapistore_root']) config['mapistore'] = mstore config['management'] = mstore.management() if config['ocsmanager']['main']['debug'] == "yes": config['management'].verbose = True; return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, "controllers"), static_files=os.path.join(root, "public"), templates=[os.path.join(root, "templates")], ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package="darengs", paths=paths) config["routes.map"] = make_map(config) config["pylons.app_globals"] = app_globals.Globals(config) config["pylons.h"] = darengs.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config["pylons.app_globals"].cache) # Create the Mako TemplateLookup, with the default auto-escaping config["pylons.app_globals"].mako_lookup = TemplateLookup( directories=paths["templates"], error_handler=handle_mako_error, module_directory=os.path.join(app_conf["cache_dir"], "templates"), input_encoding="utf-8", default_filters=["escape"], imports=["from markupsafe import escape"], ) # Setup the SQLAlchemy database engine engine = engine_from_config(config, "sqlalchemy.") init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) p1 = Popen(["python", os.path.join(DARENGS_HOME, "darengs", "lib", "JobMonitor.py")]) print "p1.pid", p1.pid return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')], cpkdir=os.path.join(root, 'cpk'), ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='doorkeeper', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = doorkeeper.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') model.init_model(engine) #init system parameters q = model.Session.query(model.DKSystem) config['pylons.app_globals'].system_params = dict([(e.key, e.val) for e in q.all()]) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='www_kaf', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = www_kaf.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from markupsafe import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # Jinja 2 environment # Create the Jinja2 Environment #config('pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader(autoescape=True) #Jinja2's unable to request c's attributes without strict_c # config['pylons.strict_c'] = True #config['pylons.app_globals'].jinja_env=Environment #config['pylons.strict_c'] = True return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='chsdi', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) pylons.cache._push_object(config['pylons.app_globals'].cache) config['pylons.h'] = chsdi.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, input_encoding='utf-8') # Setup the SQLAlchemy database engine # FIXME: convert_unicode=True ? init_model('bod', engine_from_config(config, 'sqlalchemy.bod.', pool_recycle = 20, max_overflow = -1, pool_size = 20)) init_model('stopo', engine_from_config(config, 'sqlalchemy.stopo.', pool_recycle = 55)) init_model('edi', engine_from_config(config, 'sqlalchemy.edi.', pool_recycle = 55)) init_model('search', engine_from_config(config, 'sqlalchemy.search.', pool_recycle = 20, max_overflow = -1, pool_size = 20)) init_model('bafu', engine_from_config(config, 'sqlalchemy.bafu.', pool_recycle = 55)) init_model('kogis', engine_from_config(config, 'sqlalchemy.kogis.', pool_recycle = 55)) init_model('vbs', engine_from_config(config, 'sqlalchemy.vbs.', pool_recycle = 55)) init_model('are', engine_from_config(config, 'sqlalchemy.are.', pool_recycle = 55)) init_model('uvek', engine_from_config(config, 'sqlalchemy.uvek.', pool_recycle = 55)) init_model('ivs2b', engine_from_config(config, 'sqlalchemy.ivs2b.', pool_recycle = 55)) init_model('dritte', engine_from_config(config, 'sqlalchemy.dritte.', pool_recycle = 55)) init_model('bak', engine_from_config(config, 'sqlalchemy.bak.', pool_recycle = 55)) init_model('zeitreihen', engine_from_config(config, 'sqlalchemy.zeitreihen.', pool_recycle = 55)) init_model('clientdata', engine_from_config(config, 'sqlalchemy.clientdata.', pool_recycle = 55)) init_model('evd', engine_from_config(config, 'sqlalchemy.evd.', pool_recycle = 55)) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, "controllers"), static_files=os.path.join(root, "public"), templates=[os.path.join(root, "templates")], ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package="pacemaker", paths=paths) config["routes.map"] = make_map(config) config["pylons.app_globals"] = app_globals.Globals(config) config["pylons.h"] = pacemaker.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config["pylons.app_globals"].cache) # Create the Mako TemplateLookup, with the default auto-escaping config["pylons.app_globals"].mako_lookup = TemplateLookup( directories=paths["templates"], error_handler=handle_mako_error, module_directory=os.path.join(app_conf["cache_dir"], "templates"), input_encoding="utf-8", default_filters=["escape"], imports=["from webhelpers.html import escape"], ) # Setup the SQLAlchemy database engine engine = engine_from_config(config, "sqlalchemy.") init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # don't raise AttributeError for template context config["pylons.strict_tmpl_context"] = False return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='darengs', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = darengs.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from markupsafe import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) p1 = Popen([ "python", os.path.join(DARENGS_HOME, "darengs", "lib", "JobMonitor.py") ]) print("p1.pid", p1.pid) return config
def load_environment(global_conf, app_conf): """ Configures the Pylons environment via the ``pylons.config`` object. ``global_conf`` Global configuration. ``app_conf`` Application configuration. """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='debexpo', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = debexpo.lib.helpers import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) #config['pylons.strict_c'] = False #config['pylons.tmpl_context_attach_args'] = True # Customize templating options via this variable config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape', 'from debexpo.lib.filters import semitrusted']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object""" config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='ocsmanager', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = ocsmanager.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) ocsconfig = OCSConfig.OCSConfig(global_conf['__file__']) config['ocsmanager'] = ocsconfig.load() config['samba'] = _load_samba_environment() config['ocdb'] = get_openchangedb(config['samba']['samdb_ldb'].lp) mapistore.set_mapping_path(config['ocsmanager']['main']['mapistore_data']) mstore = mapistore.MAPIStore( config['ocsmanager']['main']['mapistore_root']) config['mapistore'] = mstore config['management'] = mstore.management() if config['ocsmanager']['main']['debug'] == "yes": config['management'].verbose = True return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='fademo', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = fademo.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy^W Elixir database engine engine = engine_from_config(config, 'sqlalchemy.') if model.elixir.options_defaults.get('autoload'): # Reflected tables model.elixir.bind = engine model.metadata.bind = engine model.elixir.setup_all() else: # Non-reflected tables model.init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options if is_pylons_0: config = pylons_config else: config = PylonsConfig() config.init_app(global_conf, app_conf, package='fts3rest', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = fts3rest.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # If fts3.config is set, load configuration from there fts3_config_file = config.get('fts3.config') if fts3_config_file: fts3cfg = fts3_config.fts3_config_load(fts3_config_file) # Let the database be overriden by fts3rest.ini if 'sqlalchemy.url' in config and 'sqlalchemy.url' in fts3cfg: del fts3cfg['sqlalchemy.url'] config.update(fts3cfg) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.', pool_recycle = 7200) init_model(engine) # Mako templating config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], ) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='projectname', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = projectname.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( paths['templates'], auto_reload=True) # Create the Jinja2 Environment config['pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader( [FileSystemLoader(path) for path in paths['templates']])) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')], cpkdir=os.path.join(root,'cpk'), ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='doorkeeper', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = doorkeeper.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') model.init_model(engine) #init system parameters q = model.Session.query(model.DKSystem) config['pylons.app_globals'].system_params = dict([(e.key, e.val) for e in q.all()]) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # import our private.ini that holds keys, etc imp = global_conf.get('import') if imp: cp = ConfigParser() cp.read(imp) global_conf.update(cp.defaults()) if cp.has_section('APP'): app_conf.update(cp.items('APP')) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='linkdrop', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) import linkdrop.lib.helpers as h config['pylons.h'] = h # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, "controllers"), static_files=os.path.join(root, "public"), templates=[os.path.join(root, "templates")], ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package="anagrams", paths=paths) config["routes.map"] = make_map(config) config["pylons.app_globals"] = app_globals.Globals(config) config["pylons.h"] = anagrams.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config["pylons.app_globals"].cache) # Create the Mako TemplateLookup, with the default auto-escaping config["pylons.app_globals"].mako_lookup = TemplateLookup( directories=paths["templates"], error_handler=handle_mako_error, module_directory=os.path.join(app_conf["cache_dir"], "templates"), input_encoding="utf-8", default_filters=["escape"], imports=["from webhelpers.html import escape"], ) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) from sqlobject import sqlhub, connectionForURI connection = connectionForURI(config["app_conf"]["dburi"]) sqlhub.processConnection = connection return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='darecactus', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = darecactus.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from markupsafe import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) #kill if any previous process of jobmonitoring exist p1 = Popen(["python", os.path.join(DARECACTUS_HOME,"darecactus","lib", "jobmonitor.py")]) #print "p1.pid",p1.pid return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='projectname', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = projectname.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( paths['templates'], auto_reload=True) # Create the Jinja2 Environment config['pylons.app_globals'].jinja2_env = Environment(loader=ChoiceLoader( [FileSystemLoader(path) for path in paths['templates']])) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='battleplan', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = battleplan.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config["pylons.app_globals"].systems = init_systems() config["pylons.app_globals"].jumps = init_jumps() config["pylons.app_globals"].alliances = [unicode(a.strip()) for a in list(open(config["alliance_list"]))] config["pylons.app_globals"].check_api = asbool(config['check_api']) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='nipapwww', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = nipapwww.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Jinja2 Environment jinja2_env = Environment(autoescape=True, extensions=['jinja2.ext.autoescape'], loader=FileSystemLoader(paths['templates'])) config['pylons.app_globals'].jinja2_env = jinja2_env # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['pylons.strict_c'] = False # Make sure that there is a configuration object cfg = NipapConfig(config['nipap_config_path'], { 'auth_cache_timeout': '3600' }) # set XML-RPC URI in pynipap module pynipap.xmlrpc_uri = cfg.get('www', 'xmlrpc_uri') return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='pyfisheyes', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = pyfisheyes.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', output_encoding='utf-8', imports=['from webhelpers.html import escape'], default_filters=['escape']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') # syslogdb_engine = engine_from_config(config, 'syslogdb.') init_model(engine) # tmpl_options['mako.default_filters']= ['decode.utf8'] # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='webui', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = webui.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) #As of version 1.0, the tmpl_context (a.k.a 'c'), is no longer a AttribSafeContextObj by default. #This means accessing attributes that don't exist will raise an AttributeError. #Adding the line below to the config/environment.py, to use the attribute-safe tmpl_context: config['pylons.strict_tmpl_context'] = False return config
def load_environment(global_conf, app_conf): """ Configure the Pylons environment via the ``pylons.config`` object. """ import pylons # Create config object config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='pyroscope', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = pyroscope.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) pylons.strict_c = True # Optionally, if removing the CacheMiddleware and using the # cache in the new 1.0 style, add under the previous lines: ##pylons.cache._push_object(config['pylons.app_globals'].cache) # Return config object return config
def load_environment(make_map_function, root_path, global_conf={}, app_conf={}): paths = { 'root': root_path, 'controllers': os.path.join(root_path, 'controllers'), 'templates': [os.path.join(root_path, 'templates')], 'static_files': os.path.join(root_path, 'public') } print 'Templates path: ' + os.path.join(root_path, 'templates') config = PylonsConfig() config.init_app(global_conf, app_conf, package='pycloud', paths=paths) config['routes.map'] = make_map_function(config) config['pylons.app_globals'] = Globals(config) config['debug'] = True config['pylons.h'] = helpers # For backwards compat with 0.9.7. This prevents errors from showing up when attributes from c that do not exist # are used. config['pylons.strict_tmpl_context'] = False # Clean up the system. This must be called after the object is already created config['pylons.app_globals'].cloudlet.cleanup_system() # Set up environment for all mako templates. config["pylons.app_globals"].mako_lookup = TemplateLookup( directories=paths["templates"], input_encoding="utf-8", imports=[ "from pylons import tmpl_context as c, app_globals, request", "from pylons.i18n import _, ungettext", "from pycloud.pycloud.pylons.lib import helpers as h" ]) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict( root=root, controllers=os.path.join(root, 'controllers'), data=os.path.join(root, 'data'), static_files=os.path.join(root, 'public'), templates=os.path.join(root, 'templates'), ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='muse', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = muse.lib.helpers # Setup cache object as early as possible pylons.cache._push_object(config['pylons.app_globals'].cache) # Setup cache options dict to pass to @cache.beaker_cache. config['cache_options'] = { 'query_args': True, 'expire': config.get('cache_expire', 3600), 'invalidate_on_startup': True } config['cache_options_nonpage'] = { 'expire': config.get('cache_expire', 3600), 'invalidate_on_startup': True } # Setup SQLAlchemy config['pylons.app_globals'].sa_engine = engine_from_config(config, 'sqlalchemy.' ) model.init_model(config['pylons.app_globals'].sa_engine) # Create tables if they don't already exist. model.metadata.create_all(bind=model.meta.engine)
def load_environment(global_conf, app_conf, setup_app=False): config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='robots', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = robots.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # Setup for the Robots app if setup_app == False: messages.load(config['queuedatafile']) poller.config = config poller.start() robotcontrol.start() return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates'), pkg_resources.resource_filename("ordf.onto", "templates")]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='openbiblio', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = openbiblio.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( paths['templates'], auto_reload=True) # CONFIGURATIOr OPTIONS HERE (note: all config options will override # any Pylons config options) openbiblio.handler = init_handler(config) config['pylons.strict_tmpl_context'] = False return config
def load_environment(global_conf, app_conf, with_db=True): """Configure the Pylons environment via the ``pylons.config`` object """ # Pylons paths conf_copy = global_conf.copy() conf_copy.update(app_conf) site_templates = create_site_subdirectory('templates', app_conf=conf_copy) root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) client_containing = app_conf.get('adhocracy.client_location') if client_containing: client_root = os.path.join(client_containing, 'adhocracy_client') sys.path.insert(0, client_containing) import adhocracy_client.static sys.modules['adhocracy.static'] = adhocracy_client.static else: client_root = root import adhocracy.static paths = dict( root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(client_root, 'static'), templates=[site_templates, os.path.join(client_root, 'templates')]) # Initialize config with the basic options config = PylonsConfig() config.init_app(global_conf, app_conf, package='adhocracy', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = adhocracy.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from markupsafe import escape']) config['pylons.strict_tmpl_context'] = False # Setup the SQLAlchemy database engine engineOpts = {} if asbool(config.get('adhocracy.debug.sql', False)): engineOpts['connectionproxy'] = TimerProxy() engine = engine_from_config(config, 'sqlalchemy.', **engineOpts) init_model(engine) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) init_site(config) if with_db: init_search() init_democracy() RQConfig.setup_from_config(config) return config
def load_environment(global_conf, app_conf, initial=False, test_env=None, test_index=None): """ Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='kallithea', paths=paths) # store some globals into kallithea kallithea.CELERY_ON = str2bool(config['app_conf'].get('use_celery')) kallithea.CELERY_EAGER = str2bool( config['app_conf'].get('celery.always.eager')) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = helpers kallithea.CONFIG = config load_rcextensions(root_path=config['here']) # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # sets the c attribute access when don't existing attribute are accessed config['pylons.strict_tmpl_context'] = True test = os.path.split(config['__file__'])[-1] == 'test.ini' if test: if test_env is None: test_env = not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)) if test_index is None: test_index = not int( os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)) if os.environ.get('TEST_DB'): # swap config if we pass enviroment variable config['sqlalchemy.db1.url'] = os.environ.get('TEST_DB') from kallithea.lib.utils import create_test_env, create_test_index from kallithea.tests import TESTS_TMP_PATH #set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and #test repos if test_env: create_test_env(TESTS_TMP_PATH, config) #set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests if test_index: create_test_index(TESTS_TMP_PATH, config, True) DbManage.check_waitress() # MULTIPLE DB configs # Setup the SQLAlchemy database engine sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') init_model(sa_engine_db1) set_available_permissions(config) repos_path = make_ui('db').configitems('paths')[0][1] config['base_path'] = repos_path set_app_settings(config) instance_id = kallithea.CONFIG.get('instance_id') if instance_id == '*': instance_id = '%s-%s' % (platform.uname()[1], os.getpid()) kallithea.CONFIG['instance_id'] = instance_id # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # store config reference into our module to skip import magic of # pylons kallithea.CONFIG.update(config) set_vcs_config(kallithea.CONFIG) #check git version check_git_version() if str2bool(config.get('initial_repo_scan', True)): repo2db_mapper(ScmModel().repo_scan(repos_path), remove_obsolete=False, install_git_hook=False) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object. .. note:: This is where the ``regexp`` operator for SQLite is defined and where the ``PRAGMA`` command is issued to make SQLite LIKE queries case-sensitive. """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='onlinelinguisticdatabase', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = onlinelinguisticdatabase.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) engine = engine_from_config(config, 'sqlalchemy.') # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # Patch the SQLAlchemy database engine if SQLite is the RDBMS. Add a REGEXP # function and make LIKE searches case-sensitive. RDBMSName = config['sqlalchemy.url'].split(':')[0] app_globals.RDBMSName = RDBMSName if RDBMSName == 'sqlite': # Try to use the event API of SQLA>=0.7; otherwise use a PoolListener a l SQLA ca. 0.5.8 try: from sqlalchemy import event from sqlalchemy.engine import Engine @event.listens_for(Engine, 'connect') def sqlite_patches(dbapi_connection, connection_record): # Define a regexp function for SQLite, def regexp(expr, item): """This is the Python re-based regexp function that we provide for SQLite. Note that searches will be case-sensitive by default. Such behaviour is assured in MySQL by inserting COLLATE expressions into the query (cf. in SQLAQueryBuilder.py). """ patt = re.compile(expr) try: return item and patt.search(item) is not None # This will make regexp searches work on int, date & datetime fields. except TypeError: return item and patt.search(str(item)) is not None dbapi_connection.create_function('regexp', 2, regexp) # Make LIKE searches case-sensitive in SQLite. cursor = dbapi_connection.cursor() cursor.execute("PRAGMA case_sensitive_like=ON") cursor.close() except ImportError: from sqlalchemy.interfaces import PoolListener class SQLiteSetup(PoolListener): """A PoolListener used to provide the SQLite dbapi with a regexp function. """ def connect(self, conn, conn_record): conn.create_function('regexp', 2, self.regexp) def regexp(self, expr, item): """This is the Python re-based regexp function that we provide for SQLite. Note that searches will be case-sensitive by default, which may not be the default for the MySQL regexp, depending on the collation.""" patt = re.compile(expr) try: return item and patt.search(item) is not None # This will make regexp searches work on int, date & datetime fields. # I think this is desirable ... except TypeError: return item and patt.search(str(item)) is not None engine = engine_from_config(config, 'sqlalchemy.', listeners=[SQLiteSetup()]) # Make LIKE searches case sensitive in SQLite engine.execute('PRAGMA case_sensitive_like=ON') init_model(engine) # start foma worker -- used for long-running tasks like FST compilation foma_worker = start_foma_worker() return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options if is_pylons_0: config = pylons_config else: config = PylonsConfig() config.init_app(global_conf, app_conf, package='fts3rest', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = fts3rest.lib.helpers # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # If fts3.config is set, load configuration from there fts3_config_file = config.get('fts3.config') if fts3_config_file: fts3cfg = fts3_config_load(fts3_config_file) # Let the database be overriden by fts3rest.ini if 'sqlalchemy.url' in config and 'sqlalchemy.url' in fts3cfg: del fts3cfg['sqlalchemy.url'] config.update(fts3cfg) # Setup the SQLAlchemy database engine kwargs = dict() if config['sqlalchemy.url'].startswith('mysql://'): import MySQLdb.cursors kwargs['connect_args'] = {'cursorclass': MySQLdb.cursors.SSCursor} engine = engine_from_config(config, 'sqlalchemy.', pool_recycle=7200, **kwargs) init_model(engine) # Disable for sqlite the isolation level to work around issues with savepoints if config['sqlalchemy.url'].startswith('sqlite'): @event.listens_for(engine, "connect") def do_connect(dbapi_connection, connection_record): dbapi_connection.isolation_level = None # Catch dead connections event.listens_for(engine, 'checkout')(connection_validator) event.listens_for(engine, 'connect')(connection_set_sqlmode) # Mako templating config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], ) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) return config
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object""" config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='mediadrop', paths=paths) env_dir = os.path.normpath(os.path.join(config['media_dir'], '..')) config.setdefault('env_dir', env_dir) # Initialize the plugin manager to load all active plugins plugin_mgr = PluginManager(config) mapper = create_mapper(config, plugin_mgr.controller_scan) events.Environment.before_route_setup(mapper) add_routes(mapper) events.Environment.after_route_setup(mapper) config['routes.map'] = mapper globals_ = Globals(config) globals_.plugin_mgr = plugin_mgr globals_.events = events config['pylons.app_globals'] = globals_ config['pylons.h'] = mediadrop.lib.helpers # Setup cache object as early as possible pylons.cache._push_object(globals_.cache) i18n_env_dir = os.path.join(config['env_dir'], 'i18n') config['locale_dirs'] = plugin_mgr.locale_dirs() config['locale_dirs'].update({ 'mediadrop': (os.path.join(root, 'i18n'), i18n_env_dir), 'FormEncode': (get_formencode_localedir(), i18n_env_dir), }) def enable_i18n_for_template(template): translations = Translator(pylons.translator) translations.setup(template) # Create the Genshi TemplateLoader globals_.genshi_loader = TemplateLoader( search_path=paths['templates'] + plugin_mgr.template_loaders(), auto_reload=True, max_cache_size=100, callback=enable_i18n_for_template, ) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine, config.get('db_table_prefix', None)) events.Environment.init_model() # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # TODO: Move as many of these custom options into an .ini file, or at least # to somewhere more friendly. # TODO: Rework templates not to rely on this line: # See docstring in pylons.configuration.PylonsConfig for details. config['pylons.strict_tmpl_context'] = False config['thumb_sizes'] = { # the dimensions (in pixels) to scale thumbnails Media._thumb_dir: { 's': (128, 72), 'm': (160, 90), 'l': (560, 315), }, Podcast._thumb_dir: { 's': (128, 128), 'm': (160, 160), 'l': (600, 600), }, } # END CUSTOM CONFIGURATION OPTIONS events.Environment.loaded(config) return config
def load_environment(global_conf, app_conf, initial=False): """ Configure the Pylons environment via the ``pylons.config`` object """ config = PylonsConfig() # Pylons paths root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) # store some globals into rhodecode rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery')) rhodecode.CELERY_EAGER = str2bool( config['app_conf'].get('celery.always.eager')) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = helpers rhodecode.CONFIG = config load_rcextensions(root_path=config['here']) # Setup cache object as early as possible import pylons pylons.cache._push_object(config['pylons.app_globals'].cache) # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], error_handler=handle_mako_error, module_directory=os.path.join(app_conf['cache_dir'], 'templates'), input_encoding='utf-8', default_filters=['escape'], imports=['from webhelpers.html import escape']) # sets the c attribute access when don't existing attribute are accessed config['pylons.strict_tmpl_context'] = True test = os.path.split(config['__file__'])[-1] == 'test.ini' if test: from rhodecode.lib.utils import create_test_env, create_test_index from rhodecode.tests import TESTS_TMP_PATH create_test_env(TESTS_TMP_PATH, config) create_test_index(TESTS_TMP_PATH, config, True) # MULTIPLE DB configs # Setup the SQLAlchemy database engine sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') init_model(sa_engine_db1) repos_path = make_ui('db').configitems('paths')[0][1] repo2db_mapper(ScmModel().repo_scan(repos_path)) set_available_permissions(config) config['base_path'] = repos_path set_rhodecode_config(config) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # store config reference into our module to skip import magic of # pylons rhodecode.CONFIG.update(config) return config
def load_environment(global_conf={}, app_conf={}, setup_globals=True): v1_path = get_v1_path() root_path = os.path.join(v1_path, 'v1') paths = { 'root': root_path, 'controllers': os.path.join(root_path, 'controllers'), 'templates': [os.path.join(root_path, 'templates')], } if ConfigValue.bool(global_conf.get('uncompressedJS')): paths['static_files'] = get_raw_statics_path() else: paths['static_files'] = get_built_statics_path() config = PylonsConfig() config.init_app(global_conf, app_conf, package='v1', paths=paths) # don't put action arguments onto c automatically config['pylons.c_attach_args'] = False # when accessing non-existent attributes on c, return "" instead of dying config['pylons.strict_tmpl_context'] = False g = Globals(config, global_conf, app_conf, paths) config['pylons.app_globals'] = g if setup_globals: config['v1.import_private'] = \ ConfigValue.bool(global_conf['import_private']) g.setup() g.plugins.declare_queues(g.queues) g.plugins.load_plugins(config) config['v1.plugins'] = g.plugins g.startup_timer.intermediate("plugins") config['pylons.h'] = v1.lib.helpers config['routes.map'] = make_map(config) #override the default response options config['pylons.response_options']['headers'] = {} # when mako loads a previously compiled template file from its cache, it # doesn't check that the original template path matches the current path. # in the event that a new plugin defines a template overriding a verbify # template, unless the mtime newer, mako doesn't update the compiled # template. as a workaround, this makes mako store compiled templates with # the original path in the filename, forcing it to update with the path. if "cache_dir" in app_conf: module_directory = os.path.join(app_conf['cache_dir'], 'templates') def mako_module_path(filename, uri): filename = filename.lstrip('/').replace('/', '-') path = os.path.join(module_directory, filename + ".py") return os.path.abspath(path) else: # disable caching templates since we don't know where they should go. module_directory = mako_module_path = None # set up the templating system config["pylons.app_globals"].mako_lookup = TemplateLookup( directories=paths["templates"], error_handler=handle_mako_error, module_directory=module_directory, input_encoding="utf-8", default_filters=["conditional_websafe"], filesystem_checks=getattr(g, "reload_templates", False), imports=[ "from v1.lib.filters import websafe, unsafe, conditional_websafe", "from pylons import request", "from pylons import tmpl_context as c", "from pylons import app_globals as g", "from pylons.i18n import _, ungettext", ], modulename_callable=mako_module_path, ) if setup_globals: g.setup_complete() return config