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


Python HTTPFound.headers方法代码示例

本文整理汇总了Python中pyramid.httpexceptions.HTTPFound.headers方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPFound.headers方法的具体用法?Python HTTPFound.headers怎么用?Python HTTPFound.headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.httpexceptions.HTTPFound的用法示例。


在下文中一共展示了HTTPFound.headers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from pyramid.httpexceptions import HTTPFound [as 别名]
# 或者: from pyramid.httpexceptions.HTTPFound import headers [as 别名]
    def __call__(self):

        """ login view callable """

        # convenient method to set Cache-Control and Expires headers
        self.request.response.cache_expires = 0

        dbsession = DBSession()

        params = self.request.params
        login_url = route_url('login', self.request)
        message = ''

        # playerid, password from cookie
        playerid = ''
        password = ''
        passwordFromCookie = False
        lc = self.request.cookies.get('cis_login_credentials', '')
        if lc:
            lc = lc.split('|')
            if len(lc) == 3:
                passwordFromCookie = True
                playerid = lc[0]
                password = lc[1]

        activeUser = User()
        activeUser.playerid = playerid
        activeUser.password = password

        user = None
        errors = {}
        passwordOk = False
        referrer = self.request.url

        if referrer == login_url:
            referrer = '/'

        came_from = self.request.params.get('came_from', referrer)
        url = came_from
        logged_in = authenticated_userid(self.request)
        headers = ''

        initial_login = not logged_in

        storeplayeridPwd = params.get('remember', '')

        # if already logged in and requesting this page, redirect to forbidden

        if logged_in:
            message = 'You do not have the required permissions to see this page.'
            return dict(
                    message=message,
                    url=url,
                    came_from=came_from,
                    password=password,
                    user=activeUser,
                    headers=headers,
                    errors=errors,
                    logged_in=logged_in,
                    remember=storeplayeridPwd
                    )
        # check whether we are asked to do an autologin (from pwdreset.py)
        autologin = 0 #self.request.session.pop_flash(queue='autologin')

        # 'SECURITY RISK'
        forcelogin = lc and self.request.params.get('forcelogin', '')
        if forcelogin or autologin or 'form.submitted' in params:

            if autologin:
                autologin = autologin[0].split('|')
                playerid = autologin[0]
                password = autologin[1] #encrypted
            elif forcelogin:
                pass
            else:
                playerid = params['playerid']
                # when we get a password from a cookie, we already receive it encrypted. If not, encrypt it here
                password = (passwordFromCookie and password) or params['password']

            if not password:
                errors['password'] = "Enter your password"
            else:
                # if autologin, we already receive it encrypted. If not, encrypt it here
                password = ((forcelogin or autologin) and password) or hashlib.md5(params['password']).hexdigest()

            if not playerid:
                errors['playerid'] = "Enter your player id"

            if playerid and password:
                user = dbsession.query(User).filter_by(playerid=playerid).first()

                if user:
                    passwordOk = (user.password == password)
                if not user:
                    message = 'You do not have a CIS account'
                elif user.banned:
                    message = 'Your account has been banned.'
                elif not user.activated:
                    message = 'Your account has not yet been activated'
                elif not passwordOk:
#.........这里部分代码省略.........
开发者ID:puittenbroek,项目名称:cister.db,代码行数:103,代码来源:login.py


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