Example #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='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
    )

    mongo.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)
Example #2
0
def setup_package():
    mongo.configure(config)