• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python web.found函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中web.found函数的典型用法代码示例。如果您正苦于以下问题:Python found函数的具体用法?Python found怎么用?Python found使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: signupPOST

def signupPOST(auth):
    # artificial delay (to slow down brute force attacks)
    sleep(auth.config.forced_delay)

    i = web.input()
    login = i.get('login', '').strip()
    password = i.get('password', '').strip()
    password2 = i.get('password2', '').strip()

    captcha_on = auth.session.get('captcha_on', False)
   # if captcha_on:
   #     try:
   #         checkcode_input = i.get('captcha').strip().lower()
   #         checkcode_session = auth.session.captcha_checkcode.lower()

   #         if not checkcode_input == checkcode_session:
   #             raise AuthError('Captcha validation failed: Wrong checkcode!')
   #     except (AttributeError, AuthError):
   #         auth.session.auth_error = 'captcha_wrong'
   #         web.found(auth.config.url_login)
   #         return

    if password != password2 :
        print "密码不一致!"
        return;
    
    if password == '' or login == '':
        return ;

    user_id = auth.createUser(login, password)
    web.found("/login")
    return
开发者ID:simon0227,项目名称:ClusterScriptMgr,代码行数:32,代码来源:views.py


示例2: resetChangePOST

def resetChangePOST(auth, uid, token):
    # artificial delay (to slow down brute force attacks)
    sleep(auth.config.forced_delay)

    i = web.input()
    password = i.get('password', '').strip()
    password2 = i.get('password2', '').strip()
    try:
        user = auth._db.select('user',
                               where='user_id = $uid',
                               vars={'uid': uid}).list()
        if not user:
            raise AuthError('expired')
        user = user[0]
        if not tokens.check_token(user, token, auth.config.reset_expire_after):
            raise AuthError('expired')
        if password != password2:
            raise AuthError('match')
        if len(password) < auth.config.password_minlen:
            raise AuthError('bad password')

        auth.setPassword(user.user_login, password)
        auth.login(user)
    except AuthError, e:
        auth.session.auth_error = str(e)
        web.found(web.ctx.path)
        return
开发者ID:simon0227,项目名称:ClusterScriptMgr,代码行数:27,代码来源:views.py


示例3: proxyfunc

            def proxyfunc(iself, *args, **kw):
                try:
                    #                    if pars.get('captcha_on', ''):
                    #                        if self.config.captcha_enabled:
                    #                            self.session.captcha_on = True
                    #                        else:
                    #                            raise AuthError('Captcha is disabled.')

                    print iself, "args=", args, "kw=", kw
                    user = self.session.user
                    if "perm" in pars:
                        if not self.hasPerm(pars["perm"], user):
                            raise PermissionError
                    if "test" in pars:
                        if not pars["test"](user):
                            raise AuthError

                except (AttributeError, AuthError, SessionExpired):
                    #                    print sys.exc_info(), " next=", web.ctx.fullpath, " func=", func
                    #                    pprint(web.ctx)
                    self.session.next = web.ctx.fullpath
                    return web.found(self.config.url_login)
                except (PermissionError):
                    print "permission deny"
                    return web.found(self.config.permission_deny)
                return func(iself, *args, **kw)
开发者ID:simon0227,项目名称:ClusterScriptMgr,代码行数:26,代码来源:dbauth.py


示例4: request

    def request(self):
        return_to = self.query.get('return_to', web.ctx.homedomain + web.url('/account'))

        data = filter(lambda item: item[0] not in ['password'], self.query.items())

        form = WebOpenIDLoginForm(password_manager)()

        session['no_password'] = False

        if self.method == 'POST':
            try:
                if form.validates(self.query):
                    session.login()
                    data.append(('logged_in', True))
                    return web.found(return_to + '?' + web.http.urlencode(dict(data)))

            except PasswordManager.NoPassword:
                session['no_password'] = True
                session.login()
                data.append(('logged_in', True))
                return web.found(return_to + '?' + web.http.urlencode(dict(data)))

        web.header('Content-type', 'text/html')
        return render.login(
                logged_in=session.logged_in,
                login_url=web.ctx.homedomain + web.url('/account/login'),
                logout_url=web.ctx.homedomain + web.url('/account/logout'),
                change_password_url=web.ctx.homedomain + web.url('/account/change_password'),
                no_password=session.get('no_password', False),
                form=form,
                query=data,
            )
开发者ID:imankulov,项目名称:ownopenidserver,代码行数:32,代码来源:openidserver.py


示例5: GET

    def GET(self):
        if 'facebook_access_token' not in web.ctx.session:
            raise web.found('/')

        access_token = web.ctx.session.pop('facebook_access_token')
        access_token = access_token['access_token'][-1]
        profile = json.load(
                urllib.urlopen(
                    "https://graph.facebook.com/me?" +
                    urllib.urlencode(dict(access_token=access_token))))

        user = UsersRepository.get(profile['id'])
        if not user:
            avatar = 'https://graph.facebook.com/%(id)s/picture?type=large' 
            avatar = avatar % dict(id=profile['id'])
            user = UsersRepository.add(profile['id'], profile['name'],
                                       avatar, access_token)
        user.token = access_token

        web.ctx.orm.add(user)
        web.ctx.orm.commit()
        # Merge fying and persistent object: this enables us to read the
        # automatically generated user id
        user = web.ctx.orm.merge(user)

        web.setcookie('token', user.token)

        raise web.found('/settings/parties')
开发者ID:comick,项目名称:barduino,代码行数:28,代码来源:auth.py


示例6: POST

	def POST(self, action):
		token = self.get_token()

		# Get the form and the form data.
		form = self.get_form()
		form.fill(token.dict())

		if not form.validates():
			# Failed to validate. Display the form again.
			renderer.addTemplate('action', action)
			renderer.addTemplate('form', form)
			errors = form.getnotes()
			renderer.addDataList('errors', errors)
			return renderer.render('admin/token/edit.html')
		else:
			# Validated - proceed.
			token.updated = datetime.datetime.now()
			token.token = form.token.get_value()
			token.comment = form.comment.get_value()
			token.put()

			if renderer.get_mode() == 'html':
				# Redirect to the list.
				web.found('/admin/token/')
			else:
				# Send back the source data.
				renderer.addData('token', token)
				return renderer.render('apionly.html')
开发者ID:firehot,项目名称:notifry,代码行数:28,代码来源:admin.py


示例7: GET

 def GET(self): 
     if 'user' in auth.session.keys():
         web.found(auth.config.url_after_login)
         return
     template = render.login
     auth_error = auth.session.get('auth_error','')
     if auth_error:
         del auth.session['auth_error']
     return template(error=auth_error)
开发者ID:AgentKWang,项目名称:ProjectPlaningTool,代码行数:9,代码来源:dbauth.py


示例8: loginGET

def loginGET(auth, template=None):
    if auth.session.has_key('user'):
        web.found(auth.config.url_after_login)
        return
    template = template or auth.config.template_login or render.login
    auth_error = auth.session.get('auth_error', '')
    if auth_error:
        del auth.session['auth_error']
    return template(error=auth_error, url_reset=auth.config.url_reset_token)
开发者ID:2Checkout,项目名称:2checkout-python-tutorial,代码行数:9,代码来源:views.py


示例9: GET

 def GET(self,path=None):
     ''' '/(.*)/' redirct to '/(.*)' '''
     if path:
         web.seeother('/'+path)
         return
     else:
         args = web.input()
         if 'url' in args:
             web.found(args['url'])
开发者ID:emeitu,项目名称:test,代码行数:9,代码来源:redirect.py


示例10: GET

	def GET(self):
		user = users.get_current_user()

		if user:
			# Is logged in.
			raise web.found('/profile')
		else:
			# Not logged in - redirect to login.
			raise web.found(users.create_login_url(web.url()))
开发者ID:thunderace,项目名称:newtifry,代码行数:9,代码来源:index.py


示例11: GET

 def GET(self):
     v = nvdadb.StableVersion.query.order_by(nvdadb.StableVersion.updated_on.desc()).first()
     i = web.input()
     if 'type' in i and i.type in ('portable', 'installer'):
         link = getattr(v, "%s_link" % type)
         web.found(link)
     else:
         d = v.to_dict().copy()
         d['portable'] = v.portable_link
         d['installer'] = v.installer_link
         return d
开发者ID:ragb,项目名称:nvda_snapshots_ws,代码行数:11,代码来源:ws.py


示例12: loginGET

def loginGET(auth, template=None):
    if 'user' in auth.session.keys():
        web.found(auth.config.url_after_login)
        return

    template = template or auth.config.template_login or render.login

    auth_error = auth.session.get('auth_error', '')
    if auth_error:
        del auth.session['auth_error']

    return template(error=auth_error,
                    captcha_on=auth.session.get('captcha_on', False),
                    url_reset=auth.config.url_reset_token)
开发者ID:simon0227,项目名称:ClusterScriptMgr,代码行数:14,代码来源:views.py


示例13: callback

def callback():
    i = web.input()
    code = i.get("code", None)
    if code:
        # /callback?code=xxx
        client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET)
        token = client.request_access_token(code, _CALLBACK_URL)
        logging.info("got access token: %s" % str(token))
        uid = token.uid
        kw = dict(access_token=token.access_token, expires_in=token.expires_in)
        # check for update:
        if 0 == db.update("user", where="uid=$uid", vars=dict(uid=uid), **kw):
            # create user:
            client.set_access_token(token.access_token, token.expires_in)
            user = client.get.users__show(uid=uid)
            kw["uid"] = uid
            kw["name"] = user.screen_name
            kw["gender"] = user.gender
            kw["province_code"] = user.province
            kw["city_code"] = user.city
            kw["image_url"] = user.profile_image_url
            db.insert("user", **kw)
        # make a cookie:
        web.setcookie("weibouser", _make_cookie(uid, token.access_token), int(token.expires_in - time.time()))
        raise web.found("/index")
开发者ID:baepython,项目名称:baepython_sdk,代码行数:25,代码来源:urls.py


示例14: proxyfunc

 def proxyfunc(iself, *args, **kw):
     try:
         user = self.session.user                 
     except (AttributeError, AuthError, SessionExpired):
         self.session.next = web.ctx.fullpath
         return web.found(self.config.url_login)
     return func(iself, *args, **kw)
开发者ID:AgentKWang,项目名称:ProjectPlaningTool,代码行数:7,代码来源:dbauth.py


示例15: POST

            def POST(self): 
                # artificial delay (to slow down brute force attacks)
                sleep(auth.config.forced_delay)

                i = web.input()
                login = i.get('username1', '').strip()
                password = i.get('password', '').strip()

                user = auth.authenticate(login, password)
                if not user:
                    auth.session.auth_error = 'fail'
                    web.found(auth.config.url_login)
                    return
                else:
                    auth.login(user)
                    web.found(auth.config.url_after_login)
开发者ID:AgentKWang,项目名称:ProjectPlaningTool,代码行数:16,代码来源:dbauth.py


示例16: GET

 def GET(self):
     kvdb = sae.kvdb.KVClient()
     if hasattr(self, 'update_info'):
         import time
         time.sleep(8)
         raise web.found('/howareyou')
         this_quote = self.update_info
     else:
         try:
             today_quotes = kvdb.get_by_prefix(const.QUOTE_PREFIX)
         except:
             today_quotes = Nothing() #else None is not iterable
         today_quote_probs = 0 if not today_quotes else 3.5
         try:
             weather = kvdb.get('weather')
         except:
             weather = Nothing() #else None is not iterable
         weather_probs = 0 if not weather else 2
         this_quote = Howareyou.weighted_pick([(quotes, 1), ([q[1] for q in today_quotes], today_quote_probs), ([weather], weather_probs)])
     # this_quote = random.choice(quotes)
     # if web.input().get('from') == 'poly':
     # this_quote = '''<p><b>松江天气(<a href='http://www.weather.com.cn/weather/101020900.shtml'>11/21 10:00</a>)</b></p>小雨转小到中雨,东风3-4级,12℃~15℃,当前气温8°。'''
     web.header('Content-Type', 'text/html; charset=utf-8', unique=True)
     web.header('Content-Length', len(this_quote), unique=True)
     web.header('X-How-Are-You', 'fine', unique=True)
     return this_quote
开发者ID:PeterRao,项目名称:dhunews-sae,代码行数:26,代码来源:howareyou.py


示例17: GET

    def GET(self):
        import uuid
        import datetime
        db = web.config._db
        session = web.config._session

        web.header('Content-Type', 'text/html; charset=utf-8', unique=True)
        code = web.input().code
        state = web.input().state
        cookie_state = web.cookies().get('qqstate')
        if state != cookie_state:
            raise web.Forbidden()

        if code:
            access_token = self.get_access_token(code)
            openid = self.get_openid(access_token)
            nickname = self.get_nickname(access_token, openid)

            oauth_user_id = 'qq:' + openid
            user = web.ctx.db.query(db.User).filter_by(oauth_user_id=oauth_user_id).first()
            if not user:
                user = db.User(openid)
                user.app_id = str(uuid.uuid1())
                user.user_name = nickname
                user.oauth_user_id = oauth_user_id
                user.created_on = datetime.datetime.now()
                web.ctx.db.add(user)
                web.ctx.db.commit()

            session.user = web.storage(app_id=user.app_id, user_id=user.user_id, user_name=user.user_name) 
            logging.info('qq logined:%s', session.user)
            
            return web.found('/')
开发者ID:cluo,项目名称:warning-collector,代码行数:33,代码来源:qqlogin.py


示例18: POST

    def POST(self):
        user = self.current_user
        user.party_id = web.input(party_id=None).party_id

        web.ctx.orm.add(user)
        web.ctx.orm.commit()
        raise web.found('/settings/tubi')
开发者ID:comick,项目名称:barduino,代码行数:7,代码来源:parties.py


示例19: GET

 def GET(self):
     if auth.get_user():
         raise web.found('/?edit')
     if web.ctx.env.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest':
         return render_partial.auth.login(loginForm())
     else:
         return render.auth.login(loginForm())
开发者ID:w0rm,项目名称:pre-stonegarden-dev,代码行数:7,代码来源:auth.py


示例20: request

    def request(self):
        # check for login
        if not session.logged_in:
            return WebOpenIDLoginRequired(self.query)

        form = WebOpenIDChangePasswordForm()

        if self.method == 'POST':
            if form.validates(self.query):
                password_manager.set(self.query['password'])

                session['no_password'] = False

                return web.found(
                    homedomain(web.ctx) + web.url('/account'))

        web.header('Content-type', 'text/html')
        return render.password(
            home_url=homedomain(web.ctx) + web.url('/'),
            logged_in=session.logged_in,
            logout_url=homedomain(web.ctx) + web.url('/account/logout'),
            change_password_url=homedomain(web.ctx) + web.url(
                '/account/change_password'),
            no_password=session.get('no_password', False),
            form=form,
        )
开发者ID:yottatsa,项目名称:ownopenidserver,代码行数:26,代码来源:openidserver.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.get函数代码示例发布时间:2022-05-26
下一篇:
Python web.forbidden函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap