本文整理汇总了Python中gittip.security.user.User.keep_signed_in_until方法的典型用法代码示例。如果您正苦于以下问题:Python User.keep_signed_in_until方法的具体用法?Python User.keep_signed_in_until怎么用?Python User.keep_signed_in_until使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gittip.security.user.User
的用法示例。
在下文中一共展示了User.keep_signed_in_until方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: outbound
# 需要导入模块: from gittip.security.user import User [as 别名]
# 或者: from gittip.security.user.User import keep_signed_in_until [as 别名]
def outbound(response):
if 'user' in response.request.context:
user = response.request.context['user']
if not isinstance(user, User):
raise Response(400, "If you define 'user' in a simplate it has to "
"be a User instance.")
else:
user = User()
if user.ANON: # user is anonymous
if 'session' not in response.request.headers.cookie:
# no cookie in the request, don't set one on response
return
else:
# expired cookie in the request, instruct browser to delete it
response.headers.cookie['session'] = ''
expires = 0
else: # user is authenticated
response.headers['Expires'] = BEGINNING_OF_EPOCH # don't cache
response.headers.cookie['session'] = user.participant.session_token
expires = time.time() + TIMEOUT
user.keep_signed_in_until(expires)
cookie = response.headers.cookie['session']
# I am not setting domain, because it is supposed to default to what we
# want: the domain of the object requested.
#cookie['domain']
cookie['path'] = '/'
cookie['expires'] = rfc822.formatdate(expires)
cookie['httponly'] = "Yes, please."
if gittip.canonical_scheme == 'https':
cookie['secure'] = "Yes, please."