本文整理汇总了Python中pylons.configuration.PylonsConfig.update方法的典型用法代码示例。如果您正苦于以下问题:Python PylonsConfig.update方法的具体用法?Python PylonsConfig.update怎么用?Python PylonsConfig.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylons.configuration.PylonsConfig
的用法示例。
在下文中一共展示了PylonsConfig.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_environment
# 需要导入模块: from pylons.configuration import PylonsConfig [as 别名]
# 或者: from pylons.configuration.PylonsConfig import update [as 别名]
def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
"""
# Pylons paths
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
static_files=os.path.join(root, 'public'),
templates=[os.path.join(root, 'templates')])
# Initialize config with the basic options
if is_pylons_0:
config = pylons_config
else:
config = PylonsConfig()
config.init_app(global_conf, app_conf, package='fts3rest', paths=paths)
config['routes.map'] = make_map(config)
config['pylons.app_globals'] = app_globals.Globals(config)
config['pylons.h'] = fts3rest.lib.helpers
# Setup cache object as early as possible
import pylons
pylons.cache._push_object(config['pylons.app_globals'].cache)
# If fts3.config is set, load configuration from there
fts3_config_file = config.get('fts3.config')
if fts3_config_file:
fts3cfg = fts3_config.fts3_config_load(fts3_config_file)
# Let the database be overriden by fts3rest.ini
if 'sqlalchemy.url' in config and 'sqlalchemy.url' in fts3cfg:
del fts3cfg['sqlalchemy.url']
config.update(fts3cfg)
# Setup the SQLAlchemy database engine
engine = engine_from_config(config, 'sqlalchemy.', pool_recycle = 7200)
init_model(engine)
# Mako templating
config['pylons.app_globals'].mako_lookup = TemplateLookup(
directories=paths['templates'],
)
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)
return config