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

Python define.webpage函数代码示例

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

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



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

示例1: tfa_init_verify_post_

def tfa_init_verify_post_(request):
    # Extract parameters from the form
    verify_checkbox = 'verify' in request.params
    tfasecret = _get_totp_code_from_session()
    tfaresponse = request.params['tfaresponse']
    tfarecoverycodes = _get_recovery_codes_from_session()

    # Does the user want to proceed with enabling 2FA?
    if verify_checkbox and tfa.store_recovery_codes(request.userid, tfarecoverycodes):
        # Strip any spaces from the TOTP code (some authenticators display the digits like '123 456')
        tfaresponse = request.params['tfaresponse'].replace(' ', '')

        # TOTP+2FA Secret validates (activate & redirect to status page)
        if tfa.activate(request.userid, tfasecret, tfaresponse):
            # Invalidate all other login sessions
            invalidate_other_sessions(request.userid)
            # Clean up the stored session variables
            _cleanup_session()
            raise HTTPSeeOther(location="/control/2fa/status")
        # TOTP+2FA Secret did not validate
        else:
            return Response(define.webpage(request.userid, "control/2fa/init_verify.html", [
                tfarecoverycodes.split(','),
                "2fa"
            ], title="Enable 2FA: Final Step"))
    # The user didn't check the verification checkbox (despite HTML5's client-side check); regenerate codes & redisplay
    elif not verify_checkbox:
        return Response(define.webpage(request.userid, "control/2fa/init_verify.html", [
            tfarecoverycodes.split(','),
            "verify"
        ], title="Enable 2FA: Final Step"))
开发者ID:Weasyl,项目名称:weasyl,代码行数:31,代码来源:two_factor_auth.py


示例2: tfa_generate_recovery_codes_verify_password_post_

def tfa_generate_recovery_codes_verify_password_post_(request):
    userid, status = login.authenticate_bcrypt(define.get_display_name(request.userid),
                                               request.params['password'], request=None)
    # The user's password failed to authenticate
    if status == "invalid":
        return Response(define.webpage(
            request.userid,
            "control/2fa/generate_recovery_codes_verify_password.html",
            ["password"],
            title="Generate Recovery Codes: Verify Password"
        ))
    # The user has authenticated, so continue with generating the new recovery codes.
    else:
        # Edge case prevention: Stop the user from having two Weasyl sessions open and trying
        #   to proceed through the generation process with two sets of recovery codes.
        invalidate_other_sessions(request.userid)
        # Edge case prevention: Do we have existing (and recent) codes on this session? Prevent
        #   a user from confusing themselves if they visit the request page twice.
        sess = request.weasyl_session
        gen_rec_codes = True
        if '2fa_recovery_codes_timestamp' in sess.additional_data:
            # Are the codes on the current session < 30 minutes old?
            tstamp = sess.additional_data['2fa_recovery_codes_timestamp']
            if arrow.now().timestamp - tstamp < 1800:
                # We have recent codes on the session, use them instead of generating fresh codes.
                recovery_codes = sess.additional_data['2fa_recovery_codes'].split(',')
                gen_rec_codes = False
        if gen_rec_codes:
            # Either this is a fresh request to generate codes, or the timelimit was exceeded.
            recovery_codes = tfa.generate_recovery_codes()
            _set_recovery_codes_on_session(','.join(recovery_codes))
        return Response(define.webpage(request.userid, "control/2fa/generate_recovery_codes.html", [
            recovery_codes,
            None
        ], title="Generate Recovery Codes: Save New Recovery Codes"))
开发者ID:Weasyl,项目名称:weasyl,代码行数:35,代码来源:two_factor_auth.py


示例3: tfa_generate_recovery_codes_post_

def tfa_generate_recovery_codes_post_(request):
    # Extract parameters from the form
    verify_checkbox = 'verify' in request.params
    tfaresponse = request.params['tfaresponse']
    tfarecoverycodes = _get_recovery_codes_from_session()

    # Does the user want to save the new recovery codes?
    if verify_checkbox:
        if tfa.verify(request.userid, tfaresponse, consume_recovery_code=False):
            if tfa.store_recovery_codes(request.userid, tfarecoverycodes):
                # Clean up the stored session variables
                _cleanup_session()
                # Successfuly stored new recovery codes.
                raise HTTPSeeOther(location="/control/2fa/status")
            else:
                # Recovery code string was corrupted or otherwise altered.
                raise WeasylError("Unexpected")
        else:
            return Response(define.webpage(request.userid, "control/2fa/generate_recovery_codes.html", [
                tfarecoverycodes.split(','),
                "2fa"
            ], title="Generate Recovery Codes: Save New Recovery Codes"))
    elif not verify_checkbox:
        return Response(define.webpage(request.userid, "control/2fa/generate_recovery_codes.html", [
            tfarecoverycodes.split(','),
            "verify"
        ], title="Generate Recovery Codes: Save New Recovery Codes"))
开发者ID:Weasyl,项目名称:weasyl,代码行数:27,代码来源:two_factor_auth.py


示例4: GET

    def GET(self):
        status = define.common_status_check(self.user_id)

        if status:
            return define.common_status_page(self.user_id, status)
        elif not self.user_id:
            return define.webpage(self.user_id)

        return define.webpage(self.user_id, "manage/alias.html", [
            # Alias
            useralias.select(self.user_id),
        ])
开发者ID:0x15,项目名称:weasyl,代码行数:12,代码来源:settings.py


示例5: manage_alias_get_

def manage_alias_get_(request):
    status = define.common_status_check(request.userid)

    if status:
        return Response(define.common_status_page(request.userid, status))
    elif not request.userid:
        return Response(define.webpage(request.userid))

    return Response(define.webpage(request.userid, "manage/alias.html", [
        # Alias
        useralias.select(request.userid),
    ]))
开发者ID:charmander,项目名称:weasyl,代码行数:12,代码来源:settings.py


示例6: admin_render_page

def admin_render_page(template_path, args=()):
    userid = d.get_userid()
    status = d.common_status_check(userid)

    if status:
        return d.common_status_page(userid, status)
    elif not userid:
        return d.webpage(userid)
    elif userid not in staff.ADMINS:
        return d.webpage(userid, errorcode.permission)
    else:
        return d.webpage(userid, template_path, args)
开发者ID:charmander,项目名称:weasyl,代码行数:12,代码来源:dry.py


示例7: manage_friends_

def manage_friends_(request):
    form = request.web_input(feature="", backid="", nextid="")
    form.backid = define.get_int(form.backid)
    form.nextid = define.get_int(form.nextid)

    if form.feature == "pending":
        return Response(define.webpage(request.userid, "manage/friends_pending.html", [
            frienduser.select_requests(request.userid, 20, backid=form.backid, nextid=form.nextid),
        ]))
    else:
        return Response(define.webpage(request.userid, "manage/friends_accepted.html", [
            # Friends
            frienduser.select_accepted(request.userid, 20, backid=form.backid, nextid=form.nextid),
        ]))
开发者ID:charmander,项目名称:weasyl,代码行数:14,代码来源:settings.py


示例8: control_editemailpassword_get_

def control_editemailpassword_get_(request):
    return Response(define.webpage(
        request.userid,
        "control/edit_emailpassword.html",
        [profile.select_manage(request.userid)["email"]],
        title="Edit Password and Email Address"
    ))
开发者ID:Syfaro,项目名称:weasyl,代码行数:7,代码来源:settings.py


示例9: GET

    def GET(self, name=""):
        cachename = "user/followed.html"

        form = web.input(userid="", name="", backid=None, nextid=None)
        form.name = name if name else form.name
        form.userid = define.get_int(form.userid)

        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)

        return define.webpage(self.user_id, cachename, [
            # Profile information
            userprofile,
            # User information
            profile.select_userinfo(otherid, config=userprofile['config']),
            # Relationship
            profile.select_relation(self.user_id, otherid),
            # Followed
            followuser.select_followed(self.user_id, otherid, limit=44,
                                       backid=define.get_int(form.backid), nextid=define.get_int(form.nextid)),
        ])
开发者ID:0x15,项目名称:weasyl,代码行数:27,代码来源:profile.py


示例10: 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


示例11: site_update_

def site_update_(request):
    updateid = int(request.matchdict['update_id'])
    update = SiteUpdate.query.get_or_404(updateid)
    myself = profile.select_myself(request.userid)
    comments = comment.select(request.userid, updateid=updateid)

    return Response(define.webpage(request.userid, 'etc/site_update.html', (myself, update, comments), title="Site Update"))
开发者ID:Weasyl,项目名称:weasyl,代码行数:7,代码来源:general.py


示例12: GET

 def GET(self):
     jsonb_settings = define.get_profile_settings(self.user_id)
     form_settings = {
         "allow_request": jsonb_settings.allow_collection_requests,
         "allow_notification": jsonb_settings.allow_collection_notifs,
     }
     return define.webpage(self.user_id, "manage/collection_options.html", [form_settings])
开发者ID:0x15,项目名称:weasyl,代码行数:7,代码来源:collections.py


示例13: 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


示例14: 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


示例15: admincontrol_finduser_post_

def admincontrol_finduser_post_(request):
    form = request.web_input(userid="", username="", email="")

    return Response(d.webpage(request.userid, "admincontrol/finduser.html", [
        # Search results
        moderation.finduser(request.userid, form)
    ], title="Search Users: Results"))
开发者ID:Syfaro,项目名称:weasyl,代码行数:7,代码来源:admin.py


示例16: tfa_generate_recovery_codes_verify_password_get_

def tfa_generate_recovery_codes_verify_password_get_(request):
    return Response(define.webpage(
        request.userid,
        "control/2fa/generate_recovery_codes_verify_password.html",
        [None],
        title="Generate Recovery Codes: Verify Password"
    ))
开发者ID:Weasyl,项目名称:weasyl,代码行数:7,代码来源:two_factor_auth.py


示例17: POST

    def POST(self):
        form = web.input(userid="", username="", email="")

        return define.webpage(self.user_id, "modcontrol/finduser.html", [
            # Search results
            moderation.finduser(self.user_id, form)
        ])
开发者ID:0x15,项目名称:weasyl,代码行数:7,代码来源:moderation.py


示例18: 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


示例19: GET

 def GET(self):
     extras = {
         "title": "Streaming",
     }
     rating = define.get_rating(self.user_id)
     return define.webpage(self.user_id, 'etc/streaming.html',
                           [profile.select_streaming(self.user_id, rating, 300, order_by="start_time desc")], **extras)
开发者ID:hyena,项目名称:weasyl,代码行数:7,代码来源:general.py


示例20: manage_tagfilters_get_

def manage_tagfilters_get_(request):
    return Response(define.webpage(request.userid, "manage/tagfilters.html", [
        # Blocked tags
        blocktag.select(request.userid),
        # filterable ratings
        profile.get_user_ratings(request.userid),
    ]))
开发者ID:charmander,项目名称:weasyl,代码行数:7,代码来源:settings.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python login.create函数代码示例发布时间:2022-05-26
下一篇:
Python define.render函数代码示例发布时间: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