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 config.init_app(global_conf, app_conf, package='yolanda', template_engine='mako', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = yolanda.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['pylons.response_options']['content_type'] = "application/xhtml+xml" # FIXME: this is generally wrong for other XML content model.metadata.bind = engine_from_config(config, 'sqlalchemy.') model.metadata.bind.echo = True # better safe than sorry - everything should be utf-8 tmpl_options['mako.input_encoding'] = 'utf-8'
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 config.init_app(global_conf, app_conf, package='metahash', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = metahash.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'])
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 config.init_app(global_conf, app_conf, package='swat', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = swat.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) config['pylons.strict_c'] = True
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 config.init_app(global_conf, app_conf, package='wdmmgrdf', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = wdmmgrdf.lib.helpers # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( paths['templates'], auto_reload=True) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) model.handler = init_handler(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 config.init_app(global_conf, app_conf, package='ferrox', template_engine='mako', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = ferrox.lib.helpers config['pylons.g'].sa_engine = engine_from_config(config, 'sqlalchemy.') # Customize templating options via this variable tmpl_options = config['buffet.template_options'] tmpl_options['mako.input_encoding'] = 'utf-8'
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 config.init_app(global_conf, app_conf, package='demoapp', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = demoapp.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']) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine)
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 config.init_app(global_conf, app_conf, package='fivecents', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = fivecents.lib.helpers # Jinja2 configuration # translations = get_gettext_translations() config['pylons.g'].jinja_env = Environment(loader=PackageLoader('fivecents', 'templates'), extensions=['jinja2.ext.i18n']) # config['pylons.g'].jinja_env.install_gettext_translations(translations) # Jinja's unable to request c's attributes without strict_c config['pylons.strict_c'] = True # Customize templating options via this variable tmpl_options = config['buffet.template_options']
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 config.init_app(global_conf, app_conf, package="dabo", paths=paths) config["routes.map"] = make_map() config["pylons.app_globals"] = app_globals.Globals() config["pylons.h"] = dabo.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"], )
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 config.init_app(global_conf, app_conf, package='nwrsc', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = nwrsc.lib.helpers config['nwrsc.onsite'] = asbool(config.get('nwrsc.onsite', 'false')) config['nwrsc.private'] = asbool(config.get('nwrsc.private', 'false')) if 'archivedir' not in config: config['archivedir'] = '/doesnotexist' # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = DatabaseLookup( 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; from nwrsc.lib.helpers import oneline'], default_filters=['escape'])
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__))) diracConfig = initDIRAC(root, global_conf['debug']) paths = dict(root=root, controllers=diracConfig['controllers'], static_files=diracConfig['public'], templates=diracConfig['templates']) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='dirac', template_engine='mako', paths=paths) #Add dirac configs for k in diracConfig['webConfig']: config[k] = diracConfig['webConfig'][k] config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = dirac.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] config['version'] = diracConfig['portalVersion']
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 config.init_app(global_conf, app_conf, package='theory', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = theory.lib.helpers config['pylons.strict_tmpl_context'] = False # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], 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'])
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 config.init_app(global_conf, app_conf, package="fivecents", paths=paths) config["routes.map"] = make_map() config["pylons.g"] = app_globals.Globals() config["pylons.h"] = fivecents.lib.helpers # Jinja2 configuration config["pylons.g"].jinja_env = Environment( loader=PackageLoader("fivecents", "templates", get_language=pylons_get_lang), extensions=["jinja2.ext.i18n"] ) config["pylons.g"].jinja_env.filters.update(fivecents.lib.jinja2.filters) # Jinja's unable to request c's attributes without strict_c config["pylons.strict_c"] = True
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 config.init_app(global_conf, app_conf, package='fivecents', template_engine='jinja', paths=paths) config.add_template_engine('jinja', '', { 'jinja.package': 'fivecents', 'jinja.package_path': 'templates', 'jinja.use_memcache': False, 'jinja.cache_folder': 'data/templates', 'jinja.auto_reload': True, 'jinja.extension': 'jinja', }) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = fivecents.lib.helpers # Jinja's unable to request c's attributes without strict_c config['pylons.strict_c'] = True # Customize templating options via this variable tmpl_options = config['buffet.template_options']
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 config.init_app( global_conf, app_conf, package='openspending.ui', paths=paths) config['routes.map'] = routing.make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = helpers # set log level in markdown markdown.logger.setLevel(logging.WARN) # SQLAlchemy engine = engine_from_config(config, 'openspending.db.') engine = construct_engine(engine) init_model(engine) # Configure Solr import openspending.lib.solr_util as solr solr.configure(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.abspath(__file__)) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_external_paths=[os.path.join(root, 'public', 'external')], static_development_paths=[os.path.join(root, 'public', 'development')], static_release_paths=[os.path.join(root, 'public', 'release')], static_viewer_paths=[os.path.realpath(os.path.join(root, '..', '..'))], templates=[os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='turbulenz_local', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = Globals() config['pylons.h'] = make_helpers(config) # Create the Jinja2 Environment config['pylons.app_globals'].jinja2_env = Environment(loader=FileSystemLoader(paths['templates'])) # Jinja2'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) config['pylons.response_options']['headers'] = {'Cache-Control': 'public, max-age=0', 'Pragma': 'no-cache'}
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 config.init_app(global_conf, app_conf, package='helloworld', template_engine='mako', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = helloworld.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) engine = engine_from_config(config, 'sqlalchemy.') init_model(engine)
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 config.init_app(global_conf, app_conf, package='fivecents', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = fivecents.lib.helpers # Jinja2 configuration config['pylons.g'].jinja_env = Environment(loader=PackageLoader('fivecents', 'templates'), extensions=['jinja2.ext.i18n']) # Jinja's unable to request c's attributes without strict_c config['pylons.strict_c'] = True init_model(engine_from_config(config, 'sqlalchemy.'))
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 config.init_app(global_conf, app_conf, package='forum', template_engine='mako', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = forum.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] #tmpl_options['mako.output_encoding'] = 'utf-8' #tmpl_options['genshi.output_encoding'] = 'utf-8' # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config.add_template_engine('genshi', 'forum.templates', {}) #config['pylons.response_options']['charset'] = 'utf-8' #config['pylons.request_options']['charset'] = 'utf-8' reload(sys) sys.setdefaultencoding('utf-8')
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 config.init_app(global_conf, app_conf, package="topdish", paths=paths) config["routes.map"] = make_map() config["pylons.app_globals"] = app_globals.Globals() config["pylons.h"] = topdish.lib.helpers config["pylons.strict_c"] = False # 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="utf8", output_encoding="utf8", default_filters=["escape", "decode.utf8"], imports=["from webhelpers.html import escape"], ) # Setup the SQLAlchemy database engine engine = engine_from_config(config, "sqlalchemy.topdish.") init_model(engine)
def make_app(global_conf, full_stack=True, **app_conf): # load Pylons environment root = os.path.dirname(os.path.abspath(__file__)) paths = dict( templates=[os.path.join(root, 'templates')], ) config.init_app(global_conf, app_conf, paths=paths) config['pylons.package'] = 'tests.contrib.pylons.app' config['pylons.app_globals'] = AppGlobals() # set Pylons routes config['routes.map'] = create_routes() # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], ) # define a default middleware stack app = PylonsApp() app = RoutesMiddleware(app, config['routes.map']) app = SessionMiddleware(app, config) app = CacheMiddleware(app, config) app = RegistryManager(app) return app
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 config.init_app(global_conf, app_conf, package='vault', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = vault.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']) # 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['root'] = root config['uploads.root'] = os.path.join(root, 'public') config['uploads.previews'] = os.path.join(config['uploads.root'], 'imgs', 'previews')
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 config.init_app(global_conf, app_conf, package='openspending.ui', paths=paths) config['routes.map'] = routing.make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = helpers # set log level in markdown markdown.logger.setLevel(logging.WARN) # SQLAlchemy engine = engine_from_config(config, 'openspending.db.') engine = construct_engine(engine) init_model(engine) # Configure Solr import openspending.lib.solr_util as solr solr.configure(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 config.init_app(global_conf, app_conf, package='theory', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = theory.lib.helpers config['pylons.strict_tmpl_context'] = False # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], 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']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['wwwpath'] = '.'
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 config.init_app(global_conf, app_conf, package='yap', template_engine='mako', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = yap.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['conf_file'] = 'yap.cfg'
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 config.init_app(global_conf, app_conf, package='commentonit', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = commentonit.lib.helpers # 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)
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=[file_paths['theme_public'], file_paths['public_path']], templates=[os.path.join(root, 'templates')], # apparently pylons still wants this and as a list default_theme=file_paths['base_theme'], enabled_theme=file_paths['enabled_theme']) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='zookeepr', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = zookeepr.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=[paths['enabled_theme'], paths['default_theme']], 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)
def load_api_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 config.init_app(global_conf, app_conf, package='annikki', paths=paths) config['routes.map'] = make_api_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = annikki.lib.helpers # 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.', echo = True) init_model(engine)
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ # Pylons paths from ConfigObject import ConfigObject cfg = ConfigObject(filename=os.path.expanduser('~/.afpy.cfg')) app_conf['beaker.session.secret'] = '%s' % cfg.authtkt.shared_secret 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='members', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = members.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', output_encoding='utf-8', imports=['from webhelpers.html import escape'], default_filters=['escape']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['pylons.strict_tmpl_context'] = False
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 config.init_app(global_conf, app_conf, package='debshots', paths=paths) # Don't stumble upon undefined c variables in templates (restores Pylons 0.9.6 behavior) config['pylons.strict_c'] = False config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = debshots.lib.helpers # Allow access to c.* variables that are unset config['pylons.strict_tmpl_context'] = False # 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)
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 config.init_app(global_conf, app_conf, package='classifier', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = classifier.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], 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 SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine)
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 config.init_app(global_conf, app_conf, package='mapclient', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = mapclient.lib.helpers # 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_c'] = True # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'mapclient.sqlalchemy.') engine_ckan_data = engine_from_config(config, 'vectorstore.sqlalchemy.') init_model(engine, engine_ckan_data)
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 config.init_app(global_conf, app_conf, package='fivecents', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = fivecents.lib.helpers # Jinja2 configuration config['pylons.g'].jinja2_env = Environment( loader=fivecents.lib.jinja2.PackageLoader('fivecents', 'templates', get_language=pylons_get_lang), extensions=['jinja2.ext.i18n']) config['pylons.g'].jinja2_env.filters.update(fivecents.lib.jinja2.filters) # 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) # Let this app locale is taken from environment (do not use default 'C' locale) setlocale(LC_ALL, '') check_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__ ) ) ) diracConfig = initDIRAC( root, global_conf[ 'debug' ] ) paths = dict( root = root, controllers = diracConfig[ 'controllers' ], static_files = diracConfig[ 'public' ], templates = diracConfig[ 'templates' ] ) # Initialize config with the basic options config.init_app( global_conf, app_conf, package = 'dirac', template_engine = 'mako', paths = paths ) #Add dirac configs for k in diracConfig[ 'webConfig' ]: config[ k ] = diracConfig[ 'webConfig' ][ k ] config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = dirac.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] config['version'] = diracConfig['portalVersion']
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 config.init_app(global_conf, app_conf, package='onlinelinguisticdatabase', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = onlinelinguisticdatabase.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']) # Setup the SQLAlchemy database engine # Modification: check if SQLite is RDBMS and, if so, # give the engine a SQLiteSetup listener which # provides the regexp function missing from the SQLite dbapi # (cf. http://groups.google.com/group/pylons-discuss/browse_thread/thread/8c82699e6b6a400c/5c5237c86202e2b8) SQLAlchemyURL = config['sqlalchemy.url'] rdbms = SQLAlchemyURL.split(':')[0] if rdbms == 'sqlite': engine = engine_from_config(config, 'sqlalchemy.', listeners=[SQLiteSetup()]) else: engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # Put the application settings into the app_globals object # This has the effect that when the app is restarted the globals like # objectLanguageName, metalanguageName, etc. have the correct values # Do the same for the variable app_globals attributes, e.g., sources list # I HAD TO DISABLE THE FOLLOWING TWO COMMANDS BECAUSE IT WAS CAUSING # setup-app TO CRASH BECAUSE application_settings WAS REQUESTED BEFORE THE # TABLES EXISTED! FIND ANOTHER WAY TO FIX THIS PROBLEM ... #applicationSettingsToAppGlobals(config['pylons.app_globals']) #updateSecondaryObjectsInAppGlobals(config['pylons.app_globals']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['pylons.strict_c'] = True
def bootstrap_config(self, conf): """ Loads the pylons configuration. """ path_to_ini_file = os.path.realpath(conf) conf = paste.deploy.appconfig('config:' + path_to_ini_file) pylonsconfig.init_app(conf.global_conf, conf.local_conf)
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 config.init_app(global_conf, app_conf, package='hewwolord', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = hewwolord.lib.helpers # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( paths['templates'], auto_reload=True) # Setup the SQLAlchemy database engine if 'sqlalchemy.module' in config: config['sqlalchemy.module'] = __import__(config['sqlalchemy.module']) engine = engine_from_config(config, 'sqlalchemy.') try: import coev flagdict = { 'coev.debug.lib.coev': coev.CDF_COEV, 'coev.debug.lib.coev.dump': coev.CDF_COEV_DUMP, 'coev.debug.lib.colock': coev.CDF_COLOCK, 'coev.debug.lib.colock.dump': coev.CDF_COLOCK_DUMP, 'coev.debug.lib.nbuf': coev.CDF_NBUF, 'coev.debug.lib.nbuf.dump': coev.CDF_NBUF_DUMP, 'coev.debug.lib.runq.dump': coev.CDF_RUNQ_DUMP, 'coev.debug.lib.stack': coev.CDF_STACK, 'coev.debug.lib.stack.dump': coev.CDF_STACK_DUMP } lib_debug_flags = 0 for f in flagdict: if asbool(config.get(f, False)): lib_debug_flags |= flagdict[f] coev.setdebug( asbool(config.get('coev.debug.module', False)), lib_debug_flags ) import thread thread.stack_size(int(config.get('coev.stack.size', 2 * 1024 * 1024))) except ImportError: pass mcservers = aslist(config['memcache.servers']) mcdebug = asbool(config['memcache.debug']) init_model(engine, mcservers, mcdebug)
def load_environment(global_conf={}, app_conf={}, setup_globals=True): # Setup our paths root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 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'] = os.path.join(root_path, 'public') else: paths['static_files'] = os.path.join(os.path.dirname(root_path), 'build/public') config.init_app(global_conf, app_conf, package='r2', template_engine='mako', paths=paths) g = config['pylons.g'] = Globals(global_conf, app_conf, paths) if setup_globals: g.setup() g.plugins.declare_queues(g.queues) r2.config.cache = g.cache g.plugins.load_plugins() config['r2.plugins'] = g.plugins g.startup_timer.intermediate("plugins") config['pylons.h'] = r2.lib.helpers config['routes.map'] = routing.make_map() #override the default response options config['pylons.response_options']['headers'] = {} # The following template options are passed to your template engines tmpl_options = config['buffet.template_options'] tmpl_options['mako.filesystem_checks'] = getattr(g, 'reload_templates', False) tmpl_options['mako.default_filters'] = ["mako_websafe"] tmpl_options['mako.imports'] = \ ["from r2.lib.filters import websafe, unsafe, mako_websafe", "from pylons import c, g, request", "from pylons.i18n import _, ungettext"] # 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 reddit # 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. def mako_module_path(filename, uri): module_directory = tmpl_options['mako.module_directory'] filename = filename.lstrip('/').replace('/', '-') path = os.path.join(module_directory, filename + ".py") return os.path.abspath(path) tmpl_options['mako.modulename_callable'] = mako_module_path if setup_globals: g.setup_complete()
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 config.init_app( global_conf, app_conf, package='onlinelinguisticdatabase', paths=paths ) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = onlinelinguisticdatabase.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']) # Setup the SQLAlchemy database engine # Modification: check if SQLite is RDBMS and, if so, # give the engine a SQLiteSetup listener which # provides the regexp function missing from the SQLite dbapi # (cf. http://groups.google.com/group/pylons-discuss/browse_thread/thread/8c82699e6b6a400c/5c5237c86202e2b8) SQLAlchemyURL = config['sqlalchemy.url'] rdbms = SQLAlchemyURL.split(':')[0] if rdbms == 'sqlite': engine = engine_from_config( config, 'sqlalchemy.', listeners=[SQLiteSetup()]) else: engine = engine_from_config(config, 'sqlalchemy.') init_model(engine) # Put the application settings into the app_globals object # This has the effect that when the app is restarted the globals like # objectLanguageName, metalanguageName, etc. have the correct values # Do the same for the variable app_globals attributes, e.g., sources list # I HAD TO DISABLE THE FOLLOWING TWO COMMANDS BECAUSE IT WAS CAUSING # setup-app TO CRASH BECAUSE application_settings WAS REQUESTED BEFORE THE # TABLES EXISTED! FIND ANOTHER WAY TO FIX THIS PROBLEM ... #applicationSettingsToAppGlobals(config['pylons.app_globals']) #updateSecondaryObjectsInAppGlobals(config['pylons.app_globals']) # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) config['pylons.strict_c'] = True
def load_environment(global_conf, app_conf): """ Configure the Pylons environment via the ``pylons.config`` object. This code should only need to be run once. """ # this must be run at a time when the env is semi-setup, thus inlined here. # Required by the deliverance plugin and iATI from pylons.wsgiapp import PylonsApp import pkg_resources find_controller_generic = PylonsApp.find_controller # This is from pylons 1.0 source, will monkey-patch into 0.9.7 def find_controller(self, controller): if controller in self.controller_classes: return self.controller_classes[controller] # Check to see if its a dotted name if '.' in controller or ':' in controller: ep = pkg_resources.EntryPoint.parse('x={0}'.format(controller)) if hasattr(ep, 'resolve'): # setuptools >= 10.2 mycontroller = ep.resolve() else: # setuptools >= 11.3 mycontroller = ep.load(False) self.controller_classes[controller] = mycontroller return mycontroller return find_controller_generic(self, controller) PylonsApp.find_controller = find_controller os.environ['CKAN_CONFIG'] = global_conf['__file__'] # 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=[]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='ckan', paths=paths) # Setup the SQLAlchemy database engine # Suppress a couple of sqlalchemy warnings msgs = [ '^Unicode type received non-unicode bind param value', "^Did not recognize type 'BIGINT' of column 'size'", "^Did not recognize type 'tsvector' of column 'search_vector'" ] for msg in msgs: warnings.filterwarnings('ignore', msg, sqlalchemy.exc.SAWarning) # load all CKAN plugins p.load_all(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 config.init_app(global_conf, app_conf, package='openspending.ui', paths=paths) plugins.load_all(config) # Allow plugins implementing IConfigurer to modify the config. for plugin in plugins.PluginImplementations(IConfigurer): plugin.configure(config) config['routes.map'] = routing.make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = helpers # set log level in markdown markdown.logger.setLevel(logging.WARN) # Translator (i18n) config['openspending.ui.translations'] = MultiDomainTranslator([config.get('lang', 'en')]) translator = Translator(config['openspending.ui.translations']) def template_loaded(template): translator.setup(template) # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( search_path=paths['templates'], auto_reload=True, callback=template_loaded ) init_mongo(config) # Configure ckan import openspending.lib.ckan as ckan ckan.configure(config) # Configure Solr import openspending.lib.solr_util as solr solr.configure(config) # Plugin configuration. for plugin in plugins.PluginImplementations(IConfigurable): plugin.configure(config)
def load_environment(global_conf, app_conf): """ Configure the Pylons environment via the ``pylons.config`` object. This code should only need to be run once. """ # this must be run at a time when the env is semi-setup, thus inlined here. # Required by the deliverance plugin and iATI from pylons.wsgiapp import PylonsApp import pkg_resources find_controller_generic = PylonsApp.find_controller # This is from pylons 1.0 source, will monkey-patch into 0.9.7 def find_controller(self, controller): if controller in self.controller_classes: return self.controller_classes[controller] # Check to see if its a dotted name if '.' in controller or ':' in controller: ep = pkg_resources.EntryPoint.parse('x={0}'.format(controller)) if hasattr(ep, 'resolve'): # setuptools >= 10.2 mycontroller = ep.resolve() else: # setuptools >= 11.3 mycontroller = ep.load(False) self.controller_classes[controller] = mycontroller return mycontroller return find_controller_generic(self, controller) PylonsApp.find_controller = find_controller os.environ['CKAN_CONFIG'] = global_conf['__file__'] # 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=[]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='ckan', paths=paths) # Setup the SQLAlchemy database engine # Suppress a couple of sqlalchemy warnings msgs = ['^Unicode type received non-unicode bind param value', "^Did not recognize type 'BIGINT' of column 'size'", "^Did not recognize type 'tsvector' of column 'search_vector'" ] for msg in msgs: warnings.filterwarnings('ignore', msg, sqlalchemy.exc.SAWarning) # load all CKAN plugins p.load_all(config)
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object. This code should only need to be run once. """ ###### Pylons monkey-patch # this must be run at a time when the env is semi-setup, thus inlined here. # Required by the deliverance plugin and iATI from pylons.wsgiapp import PylonsApp import pkg_resources find_controller_generic = PylonsApp.find_controller # This is from pylons 1.0 source, will monkey-patch into 0.9.7 def find_controller(self, controller): if controller in self.controller_classes: return self.controller_classes[controller] # Check to see if its a dotted name if "." in controller or ":" in controller: mycontroller = pkg_resources.EntryPoint.parse("x=%s" % controller).load(False) self.controller_classes[controller] = mycontroller return mycontroller return find_controller_generic(self, controller) PylonsApp.find_controller = find_controller ###### END evil monkey-patch os.environ["CKAN_CONFIG"] = global_conf["__file__"] # 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=[], ) # Initialize config with the basic options config.init_app(global_conf, app_conf, package="ckan", paths=paths) # Setup the SQLAlchemy database engine # Suppress a couple of sqlalchemy warnings msgs = [ "^Unicode type received non-unicode bind param value", "^Did not recognize type 'BIGINT' of column 'size'", "^Did not recognize type 'tsvector' of column 'search_vector'", ] for msg in msgs: warnings.filterwarnings("ignore", msg, sqlalchemy.exc.SAWarning) # load all CKAN plugins p.load_all(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 config.init_app(global_conf, app_conf, package='openspending.ui', paths=paths) config['routes.map'] = routing.make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = helpers # set log level in markdown markdown.logger.setLevel(logging.WARN) # Establish celery loader: from openspending.command import celery # Translator (i18n) config['openspending.ui.translations'] = MultiDomainTranslator([config.get('lang', 'en')]) translator = Translator(config['openspending.ui.translations']) def template_loaded(template): translator.setup(template) template_paths = [paths['templates'][0]] extra_template_paths = config.get('extra_template_paths', '') if extra_template_paths: # must be first for them to override defaults template_paths = extra_template_paths.split(',') + template_paths # Create the Genshi TemplateLoader config['pylons.app_globals'].genshi_loader = TemplateLoader( search_path=template_paths, auto_reload=True, callback=template_loaded ) # SQLAlchemy engine = engine_from_config(config, 'openspending.db.') engine = construct_engine(engine) init_model(engine) # Configure Solr import openspending.lib.solr_util as solr solr.configure(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__))) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'static'), templates=[site_templates, os.path.join(root, 'templates')]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='adhocracy', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() 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 webhelpers.html import escape']) # Setup the SQLAlchemy database engine engineOpts = {} if asbool(config.get('adhocracy.debug.sql', False)): engineOpts['connectionproxy'] = TimerProxy() # Work around a bug in sqlite and sqlalchemy<0.7 # See https://github.com/Pylons/pyramid/issues/174 if tuple(map(int, sqlalchemy.__version__.split('.'))) < ( 0, 7, 0) and config['sqlalchemy.url'].startswith('sqlite:'): engineOpts['poolclass'] = sqlalchemy.pool.NullPool 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() if with_db: init_search() init_democracy()
def load_environment(global_conf={}, app_conf={}, setup_globals=True): # Setup our paths root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = { 'root': root_path, 'controllers': os.path.join(root_path, 'controllers'), 'templates': tmpl_dirs, } if ConfigValue.bool(global_conf.get('uncompressedJS')): paths['static_files'] = os.path.join(root_path, 'public') else: paths['static_files'] = os.path.join(os.path.dirname(root_path), 'build/public') config.init_app(global_conf, app_conf, package='r2', template_engine='mako', paths=paths) g = config['pylons.g'] = Globals(global_conf, app_conf, paths) if setup_globals: g.setup() r2.config.cache = g.cache config['pylons.h'] = r2.lib.helpers g.plugins = config['r2.plugins'] = PluginLoader().load_plugins( g.config.get('plugins', [])) config['routes.map'] = routing.make_map() #override the default response options config['pylons.response_options']['headers'] = {} # The following template options are passed to your template engines #tmpl_options = {} #tmpl_options['myghty.log_errors'] = True #tmpl_options['myghty.escapes'] = dict(l=webhelpers.auto_link, s=webhelpers.simple_format) tmpl_options = config['buffet.template_options'] tmpl_options['mako.filesystem_checks'] = getattr(g, 'reload_templates', False) tmpl_options['mako.default_filters'] = ["mako_websafe"] tmpl_options['mako.imports'] = \ ["from r2.lib.filters import websafe, unsafe, mako_websafe", "from pylons import c, g, request", "from pylons.i18n import _, ungettext"]
def init_config(self, global_conf, app_conf): """Initialize the config object. tg.config is a proxy for pylons.config that allows attribute style access, so it's automatically setup when we create the pylons config. Besides basic initialization, this method copies all the values in base_config into the ``pylons.config`` and ``tg.config`` objects. """ pylons_config.init_app(global_conf, app_conf, package=self.package.__name__, paths=self.paths) config.update(self)
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 config.init_app(global_conf, app_conf, package='isitopen', template_engine='genshi', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = isitopen.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) engine = engine_from_config(config, 'sqlalchemy.') config['pylons.g'].sa_engine = engine # Translator (i18n) translator = Translator(ugettext) def template_loaded(template): template.filters.insert(0, translator) #translator.setup(template) # redo template setup to use genshi.search_path # This requires path notation in calls to render rather than dotted notation # e.g. render('index.html') not render('index') etc genshi = config['buffet.template_engines'].pop() # set None for template_root as not using dotted (python package) notation config.add_template_engine('genshi', None) tmpl_options = config['buffet.template_options'] tmpl_options['genshi.search_path'] = paths['templates'][0] tmpl_options["genshi.loader_callback"] = template_loaded
def load_environment(global_conf, app_conf): """Configure the Pylons environment via the ``pylons.config`` object """ # Setup the SQLAlchemy database engine manually (rather than 'from config') # so that we can pull the theme out before we set up the pylons app engine = sqlalchemy.create_engine(app_conf['sqlalchemy.url']) init_model(engine) file_paths = initialise_file_paths() # 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=[file_paths['theme_public'], file_paths['base_public']], templates=[file_paths['base_templates'] ], # apparently pylons still wants this and as a list base_templates=file_paths['base_templates'], theme_templates=file_paths['theme_templates']) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='zkpylons', paths=paths) config['routes.map'] = make_map(config) config['pylons.app_globals'] = app_globals.Globals(config) config['pylons.h'] = zkpylons.lib.helpers config['pylons.strict_tmpl_context'] = False config['pylons.package'] = 'zkpylons' # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=[paths['theme_templates'], paths['base_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 """ # 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='popserver', template_engine='mako', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = popserver.lib.helpers # easter egg :) config['pylons.response_options']['headers']['X-Pop'] = 'Ego!' # hacer que config esté disponible en el scope de popserver.lib.helpers popserver.lib.helpers.config = config # Customize templating options via this variable tmpl_options = config['buffet.template_options'] # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) # Assume that templates are encoded in utf-8 # Can override on a per-template basis using a 'magic encoding comment' tmpl_options['mako.input_encoding'] = 'utf-8' # Configures DB Engine elixir.metadata.bind = config['sqlalchemy.url'] elixir.metadata.bind.echo = True if config['sqlalchemy.echo'] == 'True' \ else None elixir.options_defaults['autosetup'] = True if asbool(config.get('popego.cache_manager.enable', False)): from popserver.config import cache cache.enable_cache()
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 config.init_app(global_conf, app_conf, package='shakespeare', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = shakespeare.lib.helpers # redo template setup to use genshi.search_path (so remove std template setup) # This requires path notation in calls to render rather than dotted notation # e.g. render('index.html') not render('index') etc # See: # http://genshi.edgewall.org/wiki/Documentation/0.5.x/plugin.html#template-paths # http://wiki.pylonshq.com/display/pylonscookbook/Template+plugins+(for+developers) # esp section: History, dotted notation vs URI notation, and the future # genshi = config['buffet.template_engines'].pop() # # set None for template_root as not using dotted (python package) notation # config.add_template_engine('genshi', None) # # tmpl_options = config['buffet.template_options'] template_paths = [paths['templates'][0]] extra_template_paths = app_conf.get('extra_template_paths', '') if extra_template_paths: # must be first for them to override defaults template_paths = extra_template_paths.split(',') + template_paths # tmpl_options['genshi.search_path'] = ':'.join(template_paths) # Create the Genshi TemplateLoader # config['pylons.app_globals'].genshi_loader = TemplateLoader( # paths['templates'], auto_reload=True) config['pylons.app_globals'].genshi_loader = TemplateLoader( template_paths, auto_reload=True) # Setup the SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine)
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 config.init_app(global_conf, app_conf, package='geoeuropeana', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = geoeuropeana.lib.helpers
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 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 if config.get('fts3.config'): fts3cfg = fts3rest.lib.helpers.fts3_config_load( config.get('fts3.config')) config.update(fts3cfg) # 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) 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 config.init_app(global_conf, app_conf, package='studio', paths=paths) # Defines custom config parameters config['resources_dir'] = os.path.join(root, 'resources') # path to mapserver dir containing default fonts and symbols config['mapserver_dir'] = os.path.join(config['resources_dir'], 'mapserver') # path to default directory datastore config['default_datastore_dir'] = os.path.join(config['resources_dir'], 'default_datastore') # path to the template including the <script> tags config['js_tmpl'] = os.path.join(paths['templates'][0], 'index.html') # Convert the debug variable from the config to a boolean value config['debug'] = asbool(config['debug']) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = studio.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', output_encoding='utf-8', imports=['from webhelpers.html import escape'], default_filters=['escape']) # Setup SQLAlchemy database engine engine = engine_from_config(config, 'sqlalchemy.') init_model(engine)
def load_environment(global_conf={}, app_conf={}): map = make_map(global_conf, app_conf) # Setup our paths root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) paths = { 'root': root_path, 'controllers': os.path.join(root_path, 'controllers'), 'templates': tmpl_dirs, 'static_files': os.path.join(root_path, 'public') } config.init_app(global_conf, app_conf, package='r2', template_engine='mako', paths=paths) config['pylons.g'] = app_globals.Globals(global_conf, app_conf, paths) config['pylons.h'] = r2.lib.helpers config['routes.map'] = map #override the default response options config['pylons.response_options']['headers'] = {} # The following template options are passed to your template engines #tmpl_options = {} #tmpl_options['myghty.log_errors'] = True #tmpl_options['myghty.escapes'] = dict(l=webhelpers.auto_link, s=webhelpers.simple_format) tmpl_options = config['buffet.template_options'] tmpl_options['mako.output_encoding'] = 'utf-8' tmpl_options['mako.input_encoding'] = 'utf-8' tmpl_options['mako.default_filters'] = ["websafe"] tmpl_options['mako.imports'] = \ ["from r2.lib.filters import websafe, unsafe", "from pylons import c, g, request", "from pylons.i18n import _, ungettext"] # Add your own template options config options here, # note that all config options will override # any Pylons config options g = config['pylons.g'] reddit_config.cache = g.cache
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__))) top = os.path.abspath(os.path.join(root, '../..')) paths = dict(root=root, controllers=os.path.join(root, 'controllers'), static_files=os.path.join(root, 'public'), templates=[ os.path.join(root, 'templates'), os.path.join(top, 'templates/base') ]) # Initialize config with the basic options config.init_app(global_conf, app_conf, package='kwmo', paths=paths) config['routes.map'] = make_map() config['pylons.app_globals'] = app_globals.Globals() config['pylons.h'] = kwmo.lib.helpers # Create the Mako TemplateLookup, with the default auto-escaping config['pylons.app_globals'].mako_lookup = TemplateLookup( directories=paths['templates'], 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']) # Get default master file path (if not defined in the paster configuration file). if not config.has_key('master_file_path'): config['master_file_path'] = RootConfigNode.master_file_path else: RootConfigNode.master_file_path = config['master_file_path'] # Cache master config. cache_master_config(path=config['master_file_path']) # Initialize models. kcd_model.init_model() # dependency - load before main model model.init_model()
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 config.init_app(global_conf, app_conf, package='srjvkk', template_engine='mako', paths=paths) config['routes.map'] = make_map() config['pylons.g'] = app_globals.Globals() config['pylons.h'] = srjvkk.lib.helpers # Customize templating options via this variable tmpl_options = config['buffet.template_options'] # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) #import psycopg2.extensions #psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) config['pylons.g'].sa_engine = sa.engine_from_config(config, 'sqlalchemy.') #config['pylons.g'].sa_engine.connect().connection.set_client_encoding("utf8") engine = config['pylons.g'].sa_engine from srjvkk import model model.init_model(config, engine) import psycopg2 as psycopg psycopg = pool.manage(psycopg)