当前位置: 首页>>代码示例>>Python>>正文


Python User.keep_signed_in_until方法代码示例

本文整理汇总了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."
开发者ID:abnor,项目名称:www.gittip.com,代码行数:34,代码来源:authentication.py


注:本文中的gittip.security.user.User.keep_signed_in_until方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。