本文整理汇总了Python中werkzeug.Request.session方法的典型用法代码示例。如果您正苦于以下问题:Python Request.session方法的具体用法?Python Request.session怎么用?Python Request.session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.Request
的用法示例。
在下文中一共展示了Request.session方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dispatch
# 需要导入模块: from werkzeug import Request [as 别名]
# 或者: from werkzeug.Request import session [as 别名]
def dispatch(self, environ, start_response):
local.application = self
request = Request(environ)
## this is where we load the cookie if any, or create a new one
sid = request.cookies.get('kif415-helfer-login')
if sid is None:
request.session = session_store.new()
else:
request.session = session_store.get(sid)
if not validate_session(request.session):
session_store.delete(request.session)
request.session = session_store.new()
request.session['logout'] = True
local.url_adapter = adapter = url_map.bind_to_environ(environ)
try:
endpoint, values = adapter.match()
handler = getattr(views, endpoint)
response = handler(request, **values)
except HTTPException, e:
response = e # XXX hrm? this breaks when setting cookies!
示例2: dispatch
# 需要导入模块: from werkzeug import Request [as 别名]
# 或者: from werkzeug.Request import session [as 别名]
def dispatch(self, environ, start_response):
local.application = self
request = Request(environ)
local.url_adapter = adapter = url_map.bind_to_environ(environ)
request.debug = self.debug
request.session = SecureCookie.load_cookie(request,
key='com.kinaj.session',
secret_key='kinaj')
try:
endpoint, values = adapter.match()
handler = getattr(views, endpoint)
response = handler(request, **values)
except NotFound, e:
response = views.not_found(request)
response.status_code = 404