本文整理汇总了Python中pyramid.configuration.Configurator.load_zcml方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.load_zcml方法的具体用法?Python Configurator.load_zcml怎么用?Python Configurator.load_zcml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.configuration.Configurator
的用法示例。
在下文中一共展示了Configurator.load_zcml方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import load_zcml [as 别名]
def setUp(self):
from pyramid.configuration import Configurator
config = Configurator(root_factory=self.root_factory)
config.begin()
config.load_zcml(self.config)
app = config.make_wsgi_app()
from webtest import TestApp
self.testapp = TestApp(app)
self.config = config
示例2: app
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.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``.
"""
config = Configurator(root_factory=get_root, settings=settings)
config.begin()
config.load_zcml('configure.zcml')
config.end()
return config.make_wsgi_app()
示例3: app
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import load_zcml [as 别名]
def app(global_config, **settings):
db_uri = settings.get('db_uri')
db_name = settings.get('db_name')
if db_uri is None or db_name is None:
raise ValueError("db_uri AND db_name must be defined"
" in application initilization configuration file")
zcml_file = settings.get('configure_zcml', 'configure.zcml')
config = Configurator(root_factory=RootFactory, settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
zodb_uri = settings.get('zodb_uri')
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.load_zcml('configure.zcml')
return config.make_wsgi_app()
示例5: setUp
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import load_zcml [as 别名]
def setUp(self):
import sys
import twill
from pyramid.configuration import Configurator
config = Configurator(root_factory=self.root_factory)
config.load_zcml(self.config)
twill.add_wsgi_intercept('localhost', 6543, config.make_wsgi_app)
if sys.platform is 'win32': # pragma: no cover
out = open('nul:', 'wb')
else:
out = open('/dev/null', 'wb')
twill.set_output(out)
testing.setUp(registry=config.registry)
示例6: main
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import load_zcml [as 别名]
def main(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')
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.load_zcml('configure.zcml')
return config.make_wsgi_app()
示例7: app
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.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.")
db_echo = settings.get('db_echo', 'false')
initialize_sql(db_string, asbool(db_echo))
config = Configurator(settings=settings)
config.begin()
config.load_zcml(zcml_file)
config.end()
return config.make_wsgi_app()
示例8: mailin_monitor_view
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.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 pyramid.authorization import ACLAuthorizationPolicy
from pyramid.configuration import Configurator
from karl.models.mailin_monitor import KarlMailInMonitor
from karl.security.policy import get_groups
from pyramid.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
from pyramid.request import Request
sub_environ = request.environ.copy()
sub_environ['SCRIPT_NAME'] = '/%s/%s' % (resource_path(context),
request.view_name)
sub_environ['PATH_INFO'] = '/' + '/'.join(request.subpath)
sub_request = Request(sub_environ)
return sub_request.get_response(_mailin_monitor_app)
示例9: app
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.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')
auth = RepozeWho1AuthenticationPolicy(identifier_name='basicauth')
acl = ACLAuthorizationPolicy()
config = Configurator(
root_factory=get_root,
settings=settings,
authorization_policy = acl,
authentication_policy = auth,
)
config.begin()
config.load_zcml(zcml_file)
config.end()
return config.make_wsgi_app()
示例10: main
# 需要导入模块: from pyramid.configuration import Configurator [as 别名]
# 或者: from pyramid.configuration.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator()
config.begin()
db_uri = settings['db_uri']
server_url = settings['server_url']
conn = Connection(db_uri)
config.registry.settings['db_conn'] = conn
config.registry.settings['server_url'] = server_url
config.registry.settings['db_name'] = settings['db_name']
config.add_subscriber(add_mongo_db, NewRequest)
config.include('pyramid_zcml')
config.load_zcml('configure.zcml')
config.end()
#add renderer
#Fixme: try to insert this on zcml file
config.add_renderer('jsonp', JSONP(param_name='callback'))
return config.make_wsgi_app()