本文整理汇总了Python中pyramid.request.Request.get_response方法的典型用法代码示例。如果您正苦于以下问题:Python Request.get_response方法的具体用法?Python Request.get_response怎么用?Python Request.get_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.request.Request
的用法示例。
在下文中一共展示了Request.get_response方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetWsdl
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import get_response [as 别名]
def testGetWsdl(self):
"""Simple test for serving of WSDL by spyne through pyramid route"""
application = PyramidApplication(
Application([self.HelloWorldService],
tns='spyne.examples.hello',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11()))
config = Configurator(settings={'debug_all': True})
config.add_route('home', '/')
config.add_view(application, route_name='home')
wsgi_app = validator(config.make_wsgi_app())
env = {
'SCRIPT_NAME': '',
'REQUEST_METHOD': 'GET',
'PATH_INFO': '/',
'QUERY_STRING': 'wsdl',
}
setup_testing_defaults(env)
request = Request(env)
resp = request.get_response(wsgi_app)
self.assert_(resp.status.startswith("200 "))
node = etree.XML(resp.body) # will throw exception if non well formed
示例2: ware
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import get_response [as 别名]
def ware(environ, start_response):
request = Request(environ)
db = environ['db.session']
session = open_session(db, request)
request.environ['gm_session'] = session
response = request.get_response(app)
save_session(db, session, request, response)
return response(environ, start_response)
示例3: mailin_monitor_view
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import get_response [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)
示例4: __call__
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import get_response [as 别名]
def __call__(self, environ, start_response):
req = Request(environ)
try:
resp = req.get_response(self.app)
except Exception, e:
# General failures get wrapped into a General KARL Error
static_url = req.relative_url(self._static_url, to_application=True)
home_url = req.relative_url(self._home_url, to_application=True)
if self._errorlog_url is None:
errorlog_url = None
else:
errorlog_url = req.relative_url(
self._errorlog_url, to_application=True
)
if isinstance(e, ReadOnlyError):
error_message = 'Site is in Read Only Mode'
error_text = READONLY_MESSAGE % {
'system_name': self._system_name}
traceback_info = None
else:
error_message = 'General Error'
error_text = GENERAL_MESSAGE % {
'system_name': self._system_name}
traceback_info = unicode(format_exc(), 'UTF-8')
resp = render_to_response(
'karl.views:templates/wsgi_errormsg.pt',
dict(error_message=error_message,
error_text=error_text,
static_url=static_url,
errorlog_url=errorlog_url,
home_url=home_url,
traceback_info=traceback_info),
)
resp.status = 500
return resp(environ, start_response)