本文整理汇总了Python中web.found函数的典型用法代码示例。如果您正苦于以下问题:Python found函数的具体用法?Python found怎么用?Python found使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了found函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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,
)
示例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')
示例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')
示例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)
示例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)
示例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'])
示例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()))
示例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
示例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)
示例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")
示例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)
示例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)