Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
def load_environment(global_conf, app_conf):
    """
    Configures the Pylons environment via the ``pylons.config`` object.

    ``global_conf``
        Global configuration.

    ``app_conf``
        Application configuration.
    """
    # 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',
                    template_engine='mako',
                    paths=paths)

    config['routes.map'] = make_map()
    config['pylons.g'] = app_globals.Globals()
    config['pylons.h'] = debexpo.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)

    # Insert soaplib contrib into the path. This is a bit of a hack and I'd
    # prefer this was gone ASAP.
    sys.path.insert(
        0, os.path.join(global_conf['here'], 'debexpo', 'contrib', 'soaplib'))

    engine = engine_from_config(config, 'sqlalchemy.')
    init_model(engine)
Exemple #4
0
def load_environment(global_conf, app_conf):
    """
    Configures the Pylons environment via the ``pylons.config`` object.

    ``global_conf``
        Global configuration.

    ``app_conf``
        Application configuration.
    """
    # 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',
                    template_engine='mako', paths=paths)

    config['routes.map'] = make_map()
    config['pylons.g'] = app_globals.Globals()
    config['pylons.h'] = debexpo.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)

    # Insert soaplib contrib into the path. This is a bit of a hack and I'd
    # prefer this was gone ASAP.
    sys.path.insert(0, os.path.join(global_conf['here'], 'debexpo', 'contrib', 'soaplib'))

    engine = engine_from_config(config, 'sqlalchemy.')
    init_model(engine)