本文整理汇总了Python中repoze.bfg.configuration.Configurator.load_zcml方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.load_zcml方法的具体用法?Python Configurator.load_zcml怎么用?Python Configurator.load_zcml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repoze.bfg.configuration.Configurator
的用法示例。
在下文中一共展示了Configurator.load_zcml方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
zcml_file = settings.get('configure_zcml', 'configure.zcml')
db_string = settings.get('db_string')
if db_string is None:
raise ValueError("No 'db_string' value in application configuration.")
initialize_sql(db_string)
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
# Ugly hack to configure the MapperExtension with the settings.
removal_extension.path = settings.get('upload_directory')
scheduler = Scheduler()
# Send out queued mails
from eportfolio.utilities.mail_delivery import trigger_queued_delivery
scheduler.add_interval_job(trigger_queued_delivery, seconds=30)
scheduler.start()
return config.make_wsgi_app()
示例2: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [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: _registerComponents
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def _registerComponents(self):
# Install a bit of configuration that make_app() usually
# does for us.
reg = get_current_registry()
config = Configurator(reg)
config.setup_registry()
config.load_zcml('opencore.includes:configure.zcml')
示例4: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
"""
zcml_file = settings.get('configure_zcml', 'configure.zcml')
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
return config.make_wsgi_app()
示例5: EPortfolioIntegrationTestCase
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [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()
示例6: _registerComponents
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def _registerComponents(self):
# Install a bit of configuration that make_app() usually
# does for us.
reg = get_current_registry()
config = Configurator(reg)
config.setup_registry()
config.load_zcml('karl.includes:configure.zcml')
from zope.interface import Interface
testing.registerAdapter(DummyToolAddables, (Interface, Interface),
IToolAddables)
示例7: ViewIntegrationTest
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
class ViewIntegrationTest(ViewTest):
def setUp(self):
import seantisinvoice
self.config = Configurator(package=seantisinvoice)
self.config.begin()
self.config.load_zcml("seantisinvoice:configure.zcml")
_initTestingDB()
def test_zcml_registration(self):
pass
示例8: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
zcml_file = settings.get('configure_zcml', 'configure.zcml')
root = Root(settings.get('amqp_host', 'localhost'),
settings.get('amqp_exchange', EXCHANGE))
config = Configurator(root_factory=lambda request: root, settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
if settings.get('debug', None):
return DebuggedApplication(config.make_wsgi_app(), True)
else:
return config.make_wsgi_app()
示例9: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def app(global_config, **settings):
""" This function returns a WSGI application.
It is usually called by the PasteDeploy framework during
``paster serve``.
"""
zodb_uri = settings.get('zodb_uri')
zcml_file = settings.get('configure_zcml', 'configure.zcml')
if zodb_uri is None:
raise ValueError("No 'zodb_uri' in application configuration.")
finder = PersistentApplicationFinder(zodb_uri, appmaker)
def get_root(request):
return finder(request.environ)
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
return config.make_wsgi_app()
示例10: mailin_monitor_view
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def mailin_monitor_view(context, request):
"""
Dispatches to a subapp from repoze.mailin.monitor. I know this looks kind
of horrible, but this is the best way I know how to mount another object
graph onto the root object graph in BFG 1.2. BFG 1.3 will theoretically
allow SCRIPT_NAME/PATH_INFO rewriting for routes of the form
'/some/path/*traverse', making it easier to do this with just a route,
rather than actually constituting a whole new bfg app just to serve this
subtree.
"""
global _mailin_monitor_app
if _mailin_monitor_app is None:
# Keep imports local in hopes that this can be removed when BFG 1.3
# comes out.
from repoze.bfg.authorization import ACLAuthorizationPolicy
from repoze.bfg.configuration import Configurator
from karl.models.mailin_monitor import KarlMailInMonitor
from karl.security.policy import get_groups
from repoze.bfg.authentication import RepozeWho1AuthenticationPolicy
authentication_policy = RepozeWho1AuthenticationPolicy(
callback=get_groups
)
authorization_policy = ACLAuthorizationPolicy()
config = Configurator(root_factory=KarlMailInMonitor(),
authentication_policy=authentication_policy,
authorization_policy=authorization_policy)
config.begin()
config.load_zcml('repoze.mailin.monitor:configure.zcml')
config.end()
_mailin_monitor_app = config.make_wsgi_app()
# Dispatch to subapp
import webob
sub_environ = request.environ.copy()
sub_environ['SCRIPT_NAME'] = '/%s/%s' % (model_path(context),
request.view_name)
sub_environ['PATH_INFO'] = '/' + '/'.join(request.subpath)
sub_request = webob.Request(sub_environ)
return sub_request.get_response(_mailin_monitor_app)
示例11: app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def app(global_config, **settings):
""" This function returns a repoze.bfg.router.Router object.
It is usually called by the PasteDeploy framework during ``paster serve``.
"""
db_string = settings.get('db_string')
if db_string is None:
raise ValueError("No 'db_string' value in application configuration.")
initialize_sql(db_string)
# Scheduler to copy recurring invoices
s = Scheduler()
# Check every 5 minutes for recurring invoices
s.add_interval_task(copy_recurring, 300)
s.start_scheduler()
config = Configurator(root_factory=RootFactory, settings=settings)
config.begin()
zcml_file = settings.get('configure_zcml', 'configure.zcml')
config.load_zcml(zcml_file)
config.end()
return config.make_wsgi_app()
示例12: wsgi_app
# 需要导入模块: from repoze.bfg.configuration import Configurator [as 别名]
# 或者: from repoze.bfg.configuration.Configurator import load_zcml [as 别名]
def wsgi_app(**settings):
config = Configurator(root_factory=get_root, settings=settings)
config.load_zcml('configure.zcml')
return config.make_wsgi_app()