本文整理汇总了Python中repoze.bfg.configuration.Configurator.hook_zca方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.hook_zca方法的具体用法?Python Configurator.hook_zca怎么用?Python Configurator.hook_zca使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repoze.bfg.configuration.Configurator
的用法示例。
在下文中一共展示了Configurator.hook_zca方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import hook_zca [as 别名]
def main(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
from repoze.bfg.authentication import AuthTktAuthenticationPolicy
from checking.authorization import RouteAuthorizationPolicy
from checking.authentication import verifyUser
if not settings.get("sqlalchemy.url"):
raise ValueError("No 'sqlalchemy.url' value in application configuration.")
config = Configurator(settings=settings,
authentication_policy=AuthTktAuthenticationPolicy("secret",
callback=verifyUser,
timeout=30*60, max_age=30*60,
reissue_time=20*60),
authorization_policy=RouteAuthorizationPolicy())
config.hook_zca()
config.begin()
setupSqlalchemy(settings)
setupRoutes(config)
setupChameleon(config)
setupi18n(config)
config.end()
app = config.make_wsgi_app()
app = TM(app)
return app
示例2: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import hook_zca [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
names = ('src_path', 'store_url', 'cache_url', 'max_entries', 'database', 'content_dir')
values = []
for name in names:
val = settings.get(name)
if val is None:
raise ValueError("No ’%s’ value in application configuration." % name)
values.append(val)
src_path, store_url, cache_url, max_entries, database, content_dir = values
zcml_file = settings.get('configure_zcml', 'configure.zcml')
config = Configurator(settings=settings, root_factory=ContentRoot(content_dir))
# use local component registry
config.hook_zca()
config.begin()
config.load_zcml(zcml_file)
register_source(src_path)
register_store(store_url, cache_url, max_entries=max_entries)
register_catalog(database)
config.end()
return config.make_wsgi_app()
示例3: EPortfolioIntegrationTestCase
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import hook_zca [as 别名]
class EPortfolioIntegrationTestCase(EPortfolioTestCase):
def setUp(self):
self.config = Configurator()
self.config.hook_zca()
self.config.begin()
self.config.load_zcml('eportfolio:configure.zcml')
_initTestingDB()