Example #1
0
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'
    # 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
Example #3
0
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
Example #4
0
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
Example #5
0
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
Example #6
0
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
Example #7
0
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
Example #8
0
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
Example #9
0
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
Example #10
0
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
Example #11
0
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()
Example #12
0
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
Example #13
0
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
Example #14
0
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
Example #15
0
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
Example #16
0
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
Example #17
0
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
Example #18
0
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
Example #19
0
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
Example #20
0
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
Example #21
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
Example #22
0
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
Example #23
0
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
Example #24
0
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
Example #25
0
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
Example #26
0
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
Example #27
0
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
Example #28
0
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
Example #29
0
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
Example #30
0
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
Example #31
0
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
Example #32
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
Example #33
0
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
Example #34
0
def load_environment(global_conf, app_conf, userscomp=None):
    """Configure the Pylons environment. Will be executed only once, when
    the application is started."""
    global compmgr, tckfilters
    config = PylonsConfig()

    do_paths(app_conf)
    parseconfig(config, global_conf, app_conf)
    setup_sysentries_cfg(config)

    # Load components
    compmgr = config['compmgr'] = open_environment(config)
    compmgr.config = config
    loadcomponents(config, global_conf, app_conf)

    # Load complex configuration files
    h.mstnccodes = open(config['zeta.mstnccodes']).read()
    h.tckccodes = open(config['zeta.tckccodes']).read()
    h.webanalytics = ''
    if isfile(config['zeta.webanalytics']):
        h.webanalytics = open(config['zeta.webanalytics']).read()

    try:
        tckfilters = eval(open(config['zeta.tckfilters']).read())
    except:
        tckfilters = []

    # Setup 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='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
Example #36
0
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
Example #37
0
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
Example #38
0
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
Example #39
0
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
Example #41
0
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
Example #42
0
    def _load_environment(self, pylonsRoot, global_conf, app_conf, GlobalsClass, helpers):
        log.pcore.debug("Loading environment...")
        """Configure the Pylons environment via the ``pylons.config``
        object
        """
        log.pcore.debug("global_conf for Pylons: %s" % str(global_conf))
        log.pcore.debug("app_conf for Pylons: %s" % str(app_conf))

        config = PylonsConfig()

        # Pylons paths
        root = os.path.abspath(pylonsRoot) #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=pylonsRoot,
                        paths=paths)

        config['routes.map'] = self._makeMap(config)
        config['pylons.app_globals'] = GlobalsClass(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'])

        # CONFIGURATION OPTIONS HERE (note: all config options will override
        # any Pylons config options)
        # TODO: call spells ???
        return config
Example #43
0
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
Example #44
0
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
Example #45
0
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
Example #46
0
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
Example #47
0
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
Example #48
0
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
Example #50
0
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
Example #51
0
def setup_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config`` object, will
    be executed when the application is setup"""
    global compmgr
    config = PylonsConfig()
    do_paths(app_conf)
    parseconfig(config, global_conf, app_conf)
    setup_sysentries_cfg(config)

    # Load components
    compmgr = config['compmgr'] = open_environment(config)
    compmgr.config = config
    loadcomponents(config, global_conf, app_conf)

    return config
Example #52
0
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')])
    try:
        logging.config.fileConfig(global_conf['__file__'])
    except:
        pass  #to make unit tests run
    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='lr', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = lr.lib.helpers
    config['pylons.response_options']['content-type'] = 'application/json'
    # 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)
    import couchdb
    import lr.lib.helpers as helpers
    server = couchdb.Server(config['couchdb.url.dbadmin'])
    db = server[config['couchdb.db.node']]
    doc = db[config['lr.nodestatus.docid']]
    doc['start_time'] = helpers.nowToISO8601Zformat()
    db.save(doc)

    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', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.strict_tmpl_context'] = False
    config['pylons.h'] = www.lib.helpers
    pylons.cache._push_object(config['pylons.app_globals'].cache)

    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=['decode.utf8'],
        imports=[])

    # Customize templating options via this variable
    # DEPRECATED
    #tmpl_options = config['buffet.template_options']
    #tmpl_options['mako.input_encoding'] = 'utf-8'
    #tmpl_options['mako.default_filters'] = ['decode.utf8']

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    return config
Example #54
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    # added to upgrade from .9.7 to 1.0
    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='gnukhata', paths=paths)

    #config['routes.map'] = make_map()
    #config['pylons.app_globals'] = app_globals.Globals()

    # added to upgrade from .9.7 to 1.0
    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.strict_tmpl_context'] = False

    config['pylons.h'] = gnukhata.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'])

    return config
Example #55
0
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)
Example #56
0
    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'])

    # 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


config = PylonsConfig()
Example #57
0
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