本文整理汇总了Python中pyramid.request.Request.relative_url方法的典型用法代码示例。如果您正苦于以下问题:Python Request.relative_url方法的具体用法?Python Request.relative_url怎么用?Python Request.relative_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.request.Request
的用法示例。
在下文中一共展示了Request.relative_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import relative_url [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)