本文整理汇总了Python中weasyl.define.errorpage函数的典型用法代码示例。如果您正苦于以下问题:Python errorpage函数的具体用法?Python errorpage怎么用?Python errorpage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了errorpage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: POST
def POST(self):
form = web.input(username="", password="", referer="", sfwmode="nsfw")
form.referer = form.referer or '/index'
logid, logerror = login.authenticate_bcrypt(form.username, form.password)
if logid and logerror == 'unicode-failure':
raise web.seeother('/signin/unicode-failure')
elif logid and logerror is None:
if form.sfwmode == "sfw":
web.setcookie("sfwmode", "sfw", 31536000)
raise web.seeother(form.referer)
elif logerror == "invalid":
return define.webpage(self.user_id, template.etc_signin, [True, form.referer])
elif logerror == "banned":
reason = moderation.get_ban_reason(logid)
return define.errorpage(
self.user_id,
"Your account has been permanently banned and you are no longer allowed "
"to sign in.\n\n%s\n\nIf you believe this ban is in error, please "
"contact [email protected] for assistance." % (reason,))
elif logerror == "suspended":
suspension = moderation.get_suspension(logid)
return define.errorpage(
self.user_id,
"Your account has been temporarily suspended and you are not allowed to "
"be logged in at this time.\n\n%s\n\nThis suspension will be lifted on "
"%s.\n\nIf you believe this suspension is in error, please contact "
"[email protected] for assistance." % (suspension.reason, define.convert_date(suspension.release)))
elif logerror == "address":
return "IP ADDRESS TEMPORARILY BLOCKED"
return define.errorpage(self.user_id)
开发者ID:dzamie,项目名称:weasyl,代码行数:33,代码来源:user.py
示例2: weasyl_exception_processor
def weasyl_exception_processor():
web.ctx.log_exc = web.ctx.env.get(
'raven.captureException', lambda **kw: traceback.print_exc())
try:
return _handle()
except ClientGoneAway:
if 'raven.captureMessage' in web.ctx.env:
web.ctx.env['raven.captureMessage']('HTTP client went away', level=logging.INFO)
return ''
except web.HTTPError:
raise
except Exception as e:
userid = d.get_userid()
errorpage_kwargs = {}
if isinstance(e, WeasylError):
if e.render_as_json:
return json.dumps({'error': {'name': e.value}})
errorpage_kwargs = e.errorpage_kwargs
if e.value in errorcode.error_messages:
web.ctx.status = errorcode.error_status_code.get(e.value, '200 OK')
message = '%s %s' % (errorcode.error_messages[e.value], e.error_suffix)
return d.errorpage(userid, message, **errorpage_kwargs)
web.ctx.status = '500 Internal Server Error'
request_id = None
if 'raven.captureException' in web.ctx.env:
request_id = base64.b64encode(os.urandom(6), '+-')
event_id, = web.ctx.env['raven.captureException'](request_id=request_id)
request_id = '%s-%s' % (event_id, request_id)
print 'unhandled error (request id %s) in %r' % (request_id, web.ctx.env)
traceback.print_exc()
if getattr(e, '__render_as_json', False):
return json.dumps({'error': {}})
return d.errorpage(userid, request_id=request_id, **errorpage_kwargs)
开发者ID:0x15,项目名称:weasyl,代码行数:33,代码来源:middleware.py
示例3: manage_thumbnail_get_
def manage_thumbnail_get_(request):
form = request.web_input(submitid="", charid="", auto="")
submitid = define.get_int(form.submitid)
charid = define.get_int(form.charid)
if submitid and request.userid not in staff.ADMINS and request.userid != define.get_ownerid(submitid=submitid):
return Response(define.errorpage(request.userid, errorcode.permissions))
elif charid and request.userid not in staff.ADMINS and request.userid != define.get_ownerid(charid=charid):
return Response(define.errorpage(request.userid, errorcode.permissions))
elif not submitid and not charid:
return Response(define.errorpage(request.userid))
if charid:
source_path = define.url_make(charid, "char/.thumb", root=True)
if os.path.exists(source_path):
source = define.url_make(charid, "char/.thumb")
else:
source = define.url_make(charid, "char/cover")
else:
try:
source = thumbnail.thumbnail_source(submitid)['display_url']
except WeasylError:
source = None
return Response(define.webpage(request.userid, "manage/thumbnail.html", [
# Feature
"submit" if submitid else "char",
# Targetid
define.get_targetid(submitid, charid),
# Thumbnail
source,
# Exists
bool(source),
], options=['imageselect'], title="Select Thumbnail"))
开发者ID:Weasyl,项目名称:weasyl,代码行数:34,代码来源:settings.py
示例4: signin_post_
def signin_post_(request):
form = request.web_input(username="", password="", referer="", sfwmode="nsfw")
form.referer = form.referer or '/'
logid, logerror = login.authenticate_bcrypt(form.username, form.password)
if logid and logerror == 'unicode-failure':
raise HTTPSeeOther(location='/signin/unicode-failure')
elif logid and logerror is None:
if form.sfwmode == "sfw":
request.set_cookie_on_response("sfwmode", "sfw", 31536000)
# Invalidate cached versions of the frontpage to respect the possibly changed SFW settings.
index.template_fields.invalidate(logid)
raise HTTPSeeOther(location=form.referer)
elif logerror == "invalid":
return Response(define.webpage(request.userid, "etc/signin.html", [True, form.referer]))
elif logerror == "banned":
reason = moderation.get_ban_reason(logid)
return Response(define.errorpage(
request.userid,
"Your account has been permanently banned and you are no longer allowed "
"to sign in.\n\n%s\n\nIf you believe this ban is in error, please "
"contact [email protected] for assistance." % (reason,)))
elif logerror == "suspended":
suspension = moderation.get_suspension(logid)
return Response(define.errorpage(
request.userid,
"Your account has been temporarily suspended and you are not allowed to "
"be logged in at this time.\n\n%s\n\nThis suspension will be lifted on "
"%s.\n\nIf you believe this suspension is in error, please contact "
"[email protected] for assistance." % (suspension.reason, define.convert_date(suspension.release))))
elif logerror == "address":
return Response("IP ADDRESS TEMPORARILY BLOCKED")
return Response(define.errorpage(request.userid))
开发者ID:charmander,项目名称:weasyl,代码行数:35,代码来源:user.py
示例5: POST
def POST(self):
form = web.input(ch_username="", ch_full_name="", ch_catchphrase="", ch_email="",
ch_birthday="", ch_gender="", ch_country="")
userid = d.get_int(form.userid)
if self.user_id != userid and userid in staff.ADMINS and self.user_id not in staff.TECHNICAL:
return d.errorpage(self.user_id, errorcode.permission)
if form.get('impersonate'):
if self.user_id not in staff.TECHNICAL:
return d.errorpage(self.user_id, errorcode.permission)
sess = web.ctx.weasyl_session
sess.additional_data.setdefault('user-stack', []).append(sess.userid)
sess.additional_data.changed()
sess.userid = userid
sess.save = True
d.append_to_log(
'staff.actions', userid=self.user_id, action='impersonate', target=userid)
raise web.seeother('/')
else:
profile.do_manage(self.user_id, userid,
username=form.username.strip() if form.ch_username else None,
full_name=form.full_name.strip() if form.ch_full_name else None,
catchphrase=form.catchphrase.strip() if form.ch_catchphrase else None,
birthday=form.birthday if form.ch_birthday else None,
gender=form.gender if form.ch_gender else None,
country=form.country if form.ch_country else None)
raise web.seeother("/admincontrol")
开发者ID:0x15,项目名称:weasyl,代码行数:27,代码来源:admin.py
示例6: signin_2fa_auth_post_
def signin_2fa_auth_post_(request):
sess = define.get_weasyl_session()
# Only render page if the session exists //and// the password has
# been authenticated (we have a UserID stored in the session)
if not sess.additional_data or '2fa_pwd_auth_userid' not in sess.additional_data:
return Response(define.errorpage(request.userid, errorcode.permission))
tfa_userid = sess.additional_data['2fa_pwd_auth_userid']
session_life = arrow.now().timestamp - sess.additional_data['2fa_pwd_auth_timestamp']
if session_life > 300:
# Maximum secondary authentication time: 5 minutes
_cleanup_2fa_session()
return Response(define.errorpage(
request.userid,
errorcode.error_messages['TwoFactorAuthenticationAuthenticationTimeout'],
[["Sign In", "/signin"], ["Return to the Home Page", "/"]]
))
elif two_factor_auth.verify(tfa_userid, request.params["tfaresponse"]):
# 2FA passed, so login and cleanup.
_cleanup_2fa_session()
login.signin(request, tfa_userid, ip_address=request.client_addr, user_agent=request.user_agent)
ref = request.params["referer"] or "/"
# User is out of recovery codes, so force-deactivate 2FA
if two_factor_auth.get_number_of_recovery_codes(tfa_userid) == 0:
two_factor_auth.force_deactivate(tfa_userid)
return Response(define.errorpage(
tfa_userid,
errorcode.error_messages['TwoFactorAuthenticationZeroRecoveryCodesRemaining'],
[["2FA Dashboard", "/control/2fa/status"], ["Return to the Home Page", "/"]]
))
# Return to the target page, restricting to the path portion of 'ref' per urlparse.
raise HTTPSeeOther(location=urlparse.urlparse(ref).path)
elif sess.additional_data['2fa_pwd_auth_attempts'] >= 5:
# Hinder brute-forcing the 2FA token or recovery code by enforcing an upper-bound on 2FA auth attempts.
_cleanup_2fa_session()
return Response(define.errorpage(
request.userid,
errorcode.error_messages['TwoFactorAuthenticationAuthenticationAttemptsExceeded'],
[["Sign In", "/signin"], ["Return to the Home Page", "/"]]
))
else:
# Log the failed authentication attempt to the session and save
sess.additional_data['2fa_pwd_auth_attempts'] += 1
sess.save = True
# 2FA failed; redirect to 2FA input page & inform user that authentication failed.
return Response(define.webpage(
request.userid,
"etc/signin_2fa_auth.html",
[define.get_display_name(tfa_userid), request.params["referer"], two_factor_auth.get_number_of_recovery_codes(tfa_userid),
"2fa"], title="Sign In - 2FA"))
开发者ID:Weasyl,项目名称:weasyl,代码行数:51,代码来源:user.py
示例7: GET
def GET(self, name=""):
form = web.input(userid="", name="", backid=None, nextid=None)
form.name = name if name else form.name
form.userid = define.get_int(form.userid)
config = define.get_config(self.user_id)
rating = define.get_rating(self.user_id)
otherid = profile.resolve(self.user_id, form.userid, form.name)
if not otherid:
raise WeasylError("userRecordMissing")
elif not self.user_id and "h" in define.get_config(otherid):
return define.errorpage(self.user_id, errorcode.no_guest_access)
userprofile = profile.select_profile(otherid, images=True, viewer=self.user_id)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = u"%s's journals" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(self.user_id, title=page_title)
page.append(define.render(template.user_journals, [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
# Relationship
profile.select_relation(self.user_id, otherid),
# Journals list
# TODO(weykent): use select_user_list
journal.select_list(self.user_id, rating, 250, otherid=otherid, config=config),
# Latest journal
journal.select_latest(self.user_id, rating, otherid=otherid),
]))
return define.common_page_end(self.user_id, page)
开发者ID:0x15,项目名称:weasyl,代码行数:34,代码来源:profile.py
示例8: GET
def GET(self):
premiumpurchase.verify(self.user_id, web.input(token="").token)
return define.errorpage(
self.user_id,
"**Success!** Your purchased premium terms have "
"been applied to your account.",
[["Go to Premium " "Settings", "/control"], ["Return to the Home Page", "/index"]])
开发者ID:dzamie,项目名称:weasyl,代码行数:7,代码来源:user.py
示例9: control_streaming_post_
def control_streaming_post_(request):
form = request.web_input(target="", set_stream="", stream_length="", stream_url="", stream_text="")
if form.target and request.userid not in staff.MODS:
return Response(define.errorpage(request.userid, errorcode.permission))
if form.target:
target = int(form.target)
else:
target = request.userid
stream_length = define.clamp(define.get_int(form.stream_length), 0, 360)
p = orm.Profile()
p.stream_text = form.stream_text
p.stream_url = define.text_fix_url(form.stream_url.strip())
set_stream = form.set_stream
profile.edit_streaming_settings(request.userid, target, p,
set_stream=set_stream,
stream_length=stream_length)
if form.target:
target_username = define.get_sysname(define.get_display_name(target))
raise HTTPSeeOther(location="/modcontrol/manageuser?name=" + target_username)
else:
raise HTTPSeeOther(location="/control")
开发者ID:Syfaro,项目名称:weasyl,代码行数:26,代码来源:settings.py
示例10: verify_account_
def verify_account_(request):
login.verify(token=request.web_input(token="").token, ip_address=request.client_addr)
return Response(define.errorpage(
request.userid,
"**Success!** Your email address has been verified "
"and you may now sign in to your account.",
[["Sign In", "/signin"], ["Return to the Home Page", "/"]]))
开发者ID:Weasyl,项目名称:weasyl,代码行数:7,代码来源:user.py
示例11: signout_
def signout_(request):
if request.web_input(token="").token != define.get_token()[:8]:
return Response(define.errorpage(request.userid, errorcode.token), status=403)
login.signout(request)
raise HTTPSeeOther(location="/", headers=request.response.headers)
开发者ID:Weasyl,项目名称:weasyl,代码行数:7,代码来源:user.py
示例12: followed_
def followed_(request):
cachename = "user/followed.html"
form = request.web_input(userid="", name="", backid=None, nextid=None)
form.name = request.matchdict.get('name', form.name)
form.userid = define.get_int(form.userid)
otherid = profile.resolve(request.userid, form.userid, form.name)
if not otherid:
raise WeasylError("userRecordMissing")
elif not request.userid and "h" in define.get_config(otherid):
return Response(define.errorpage(request.userid, errorcode.no_guest_access))
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
return Response(define.webpage(request.userid, cachename, [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
# Relationship
profile.select_relation(request.userid, otherid),
# Followed
followuser.select_followed(request.userid, otherid, limit=44,
backid=define.get_int(form.backid), nextid=define.get_int(form.nextid)),
]))
开发者ID:Syfaro,项目名称:weasyl,代码行数:27,代码来源:profile.py
示例13: verify_premium_
def verify_premium_(request):
premiumpurchase.verify(request.userid, request.web_input(token="").token)
return Response(define.errorpage(
request.userid,
"**Success!** Your purchased premium terms have "
"been applied to your account.",
[["Go to Premium " "Settings", "/control"], ["Return to the Home Page", "/"]]))
开发者ID:Weasyl,项目名称:weasyl,代码行数:7,代码来源:user.py
示例14: shouts_
def shouts_(request):
form = request.web_input(userid="", name="", backid=None, nextid=None)
form.name = request.matchdict.get('name', form.name)
form.userid = define.get_int(form.userid)
otherid = profile.resolve(request.userid, form.userid, form.name)
if not otherid:
raise WeasylError("userRecordMissing")
elif not request.userid and "h" in define.get_config(otherid):
return Response(define.errorpage(request.userid, errorcode.no_guest_access))
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = u"%s's shouts" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(request.userid, title=page_title)
page.append(define.render('user/shouts.html', [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
# Relationship
profile.select_relation(request.userid, otherid),
# Myself
profile.select_myself(request.userid),
# Comments
shout.select(request.userid, ownerid=otherid),
# Feature
"shouts",
]))
return Response(define.common_page_end(request.userid, page))
开发者ID:Syfaro,项目名称:weasyl,代码行数:33,代码来源:profile.py
示例15: verify_emailchange_get_
def verify_emailchange_get_(request):
token = request.web_input(token="").token
email = login.verify_email_change(request.userid, token)
return Response(define.errorpage(
request.userid,
"**Success!** Your email address was successfully updated to **" + email + "**.",
[["Return to the Home Page", "/"]]
))
开发者ID:Weasyl,项目名称:weasyl,代码行数:8,代码来源:user.py
示例16: POST
def POST(self, folderid):
folderid = int(folderid)
if not folder.check(self.user_id, folderid):
return define.errorpage(self.user_id, errorcode.permission)
form = web.input(settings=[])
folder.update_settings(folderid, form.settings)
raise web.seeother('/manage/folders')
开发者ID:0x15,项目名称:weasyl,代码行数:8,代码来源:settings.py
示例17: reupload_cover_get_
def reupload_cover_get_(request):
form = request.web_input(submitid="")
form.submitid = define.get_int(form.submitid)
if request.userid != define.get_ownerid(submitid=form.submitid):
return Response(define.errorpage(request.userid, errorcode.permission))
return Response(define.webpage(request.userid, "submit/reupload_cover.html", [form.submitid]))
开发者ID:makyo,项目名称:weasyl,代码行数:8,代码来源:content.py
示例18: GET
def GET(self):
form = web.input(submitid="")
form.submitid = define.get_int(form.submitid)
if self.user_id != define.get_ownerid(submitid=form.submitid):
return define.errorpage(self.user_id, errorcode.permission)
return define.webpage(self.user_id, "submit/reupload_cover.html", [form.submitid])
开发者ID:0x15,项目名称:weasyl,代码行数:8,代码来源:content.py
示例19: GET
def GET(self, folderid):
folderid = int(folderid)
if not folder.check(self.user_id, folderid):
return define.errorpage(self.user_id, errorcode.permission)
return define.webpage(self.user_id, "manage/folder_options.html", [
folder.select_info(folderid),
])
开发者ID:0x15,项目名称:weasyl,代码行数:8,代码来源:settings.py
示例20: resetpassword_post_
def resetpassword_post_(request):
form = request.web_input(token="", username="", email="", day="", month="", year="", password="", passcheck="")
resetpassword.reset(form)
return Response(define.errorpage(
request.userid,
"**Success!** Your password has been reset and you may now sign in to your account.",
[["Sign In", "/signin"], ["Return to the Home Page", "/"]]))
开发者ID:charmander,项目名称:weasyl,代码行数:8,代码来源:user.py
注:本文中的weasyl.define.errorpage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论