示例#1
0
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()
示例#2
0
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.'))
示例#3
0
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
示例#4
0
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']
示例#5
0
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']
示例#6
0
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']

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)

    # need to set environment variables explicitly because babel uses them to determine locale (it ignores locale.getlocale), 
    # also in case we want to fork some process later on
    locale.setlocale(locale.LC_ALL, config['locale'])
    for env in ['LANGUAGE', 'LANG', 'LC_CTYPE', 'LC_COLLATE', 'LC_TIME', 'LC_MONETARY', 'LC_MESSAGES', 'LC_NUMERIC', 
        'LC_PAPER', 'LC_NAME', 'LC_ADDRESS', 'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION', 'LC_ALL']:
        os.environ[env] = config['locale']