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

Python web.forbidden函数代码示例

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

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



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

示例1: PUT

    def PUT(self, id, setting):
        if setting not in self.Settings:
            web.notfound()
            return None

        try:
            configData = json.loads(web.data())

            id = int(id)
            vm = model.getVM(web.ctx.veerezoDB, id)
            if vm['user'] != web.ctx.username:
                web.forbidden()
                return None
        except (ValueError, KeyError):
            web.notfound()
            return None

        fn = '_put' + self.Settings[setting]
        f = getattr(self, fn)
        try:
            f(id, vm, configData)
        except ValueError as e:
            web.badrequest()
            return {'error': 'ValueError: {0}'.format(e.message)}

        web.nocontent()
        return None
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:27,代码来源:main.py


示例2: authenticate

 def authenticate(self, username, password):
     if not config.SECURITY:
         return True
     if users.users[username] == password:
         return True
     else:
         web.forbidden()
         return False
开发者ID:calinburloiu,项目名称:P2P-Tube,代码行数:8,代码来源:cis.py


示例3: __call__

 def __call__(self, method):
   if not self.config.hooks.pre():
     forbidden() # TODO: customize
   else:
     return {
       'GET':    self._GET,
       'PUT':    self._PUT,
       'POST':   self._POST,
       'DELETE': self._DELETE
     }.get(method, internalerror)()
开发者ID:itayd,项目名称:w,代码行数:10,代码来源:actual.py


示例4: protect

def protect(what, *a, **kw):
  try:
    return what(*a, **kw) or ""
  except (IOError, OSError) as e:
    if e.errno in [EACCES, ENOTDIR]:
      forbidden()
    else:
      internalerror()
    return str(e)
  except CalledProcessError as e:
    internalerror()
    return str(e)
开发者ID:itayd,项目名称:w,代码行数:12,代码来源:common.py


示例5: new

 def new(*args):
     uri = web.ctx.env.get('REQUEST_URI')
     key = web.ctx.env.get('HTTP_X_API_KEY')
     log = lambda status: db.insert('access_log', description=uri, date=datetime.now(), key=key, status=status)
     if not is_valid_key(key):
         log('invalid key')
         web.badrequest()
     elif exist_key(key):
         log('access')
         return fn(*args)
     else:
         log('key not found')
         web.forbidden()
开发者ID:Tippr,项目名称:itunesconnect,代码行数:13,代码来源:security.py


示例6: GET

    def GET(self, id):
        try:
            id = int(id)

            network = model.getNetwork(web.ctx.veerezoDB, id)
            if network['user'] != web.ctx.username:
                web.forbidden()
                return None

            return network
        except (ValueError, KeyError):
            web.notfound()
            return None
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:13,代码来源:main.py


示例7: DELETE

    def DELETE(self, id):
        try:
            id = int(id)

            sshkey = model.getSSHKey(web.ctx.veerezoDB, id)
            if sshkey['user'] != web.ctx.username:
                web.forbidden()
                return None

            model.deleteSSHKey(web.ctx.veerezoDB, id)
        except:
            web.notfound()
            return None

        web.nocontent()
        return None
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:16,代码来源:main.py


示例8: GET

 def GET(self):
     get_input = web.input(_method='get')
     session = get_input['session']
     response, code = session_request_get('session/%s' % session, None)
     if response.get('has_access'):
         start, count = get_pagination()
         tracks = sql.select("SELECT * FROM `tracks` LIMIT %s, %s" % (start, count))
         tracks_count = sql.select("SELECT COUNT(*) FROM `tracks`")
         tracks_json_list = []
         for track in tracks:
             track_json = {'id': str(track[0]),
                           'title': track[2],
                           'length': str(track[3]),
                           'file_size': str(track[4]),
                           'singer_id': track[1]
                          }
             tracks_json_list.append(track_json)
         result = {
             'tracks': tracks_json_list,
             'start': str(start),
             'count': str(count),
             'total_count': str(tracks_count[0][0])
         }
         web.header('Content-Type', 'json/text')
         return json.dumps(result)
     else:
         return web.forbidden()
开发者ID:markelovi,项目名称:rsoi,代码行数:27,代码来源:tracks.py


示例9: GET

 def GET(self):
     user_token = has_access()
     if user_token:
         start, count = get_pagination()
         tracks = select("SELECT * FROM `tracks` LIMIT %s, %s" % (start, count))
         tracks_count = select("SELECT COUNT(*) FROM `tracks`")
         tracks_json_list = []
         for track in tracks:
             track_json = {'id': str(track[0]),
                           'title': track[2],
                           'length': str(track[3]),
                           'file_size': str(track[4]),
                           'singer_id': track[1]
                          }
             tracks_json_list.append(track_json)
         result = {
             'tracks': tracks_json_list,
             'start': str(start),
             'count': str(count),
             'total_count': str(tracks_count[0][0])
         }
         web.header('Content-Type', 'json/text')
         return json.dumps(result)
     else:
         return web.forbidden()
开发者ID:markelovi,项目名称:rsoi,代码行数:25,代码来源:1.py


示例10: POST

    def POST(self):
        try:
            args = web.input(track_id="", token=None)
            logging.debug("Vote request: %s" % args)

            sender = auth.get_id_by_token(args.token)
            if sender is None:
                raise web.forbidden("Bad token.")

            if args.track_id.isdigit():
                track_id = int(args.track_id)
            else:
                track_id = tracks.get_last_track_id()

            weight = tracks.add_vote(track_id, sender, self.vote_value)
            if weight is None:
                return {"status": "error", "message": "No such track."}

            database.commit()

            message = 'OK, current weight of track #%u is %.04f.' % (track_id, weight)
            return {
                "status": "ok",
                "message": message,
                "id": track_id,
                "weight": weight,
            }
        except web.Forbidden:
            raise
        except Exception, e:
            log.log_error(str(e), e)
            return {"status": "error", "message": str(e)}
开发者ID:Alwnikrotikz,项目名称:ardj,代码行数:32,代码来源:server.py


示例11: __init__

    def __init__(self):
        if (self.disallow_api or self.moderator_only or self.admin_only) and weasyl.api.is_api_user():
            raise web.forbidden()

        self.user_id = define.get_userid()
        self.status = define.common_status_check(self.user_id)

        # Status check
        if self.status:
            self.replace_methods(self.status_check_fail)
            return

        # Guest check
        if self.guest_required and self.user_id != 0:
            self.replace_methods(self.login_guest_fail)
            return

        # Login check
        if self.login_required and self.user_id == 0:
            self.replace_methods(self.login_check_fail)
            return

        # Permission check
        if self.moderator_only and self.user_id not in staff.MODS:
            self.replace_methods(self.permission_check_fail)
            return
        if self.admin_only and self.user_id not in staff.ADMINS:
            self.replace_methods(self.permission_check_fail)
            return
开发者ID:0x15,项目名称:weasyl,代码行数:29,代码来源:base.py


示例12: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Cluster attributes.
        :http: * 200 (OK)
               * 400 (wrong attributes data specified)
               * 404 (cluster not found in db)
               * 500 (cluster has no attributes)
        """
        cluster = self.get_object_or_404(Cluster, cluster_id)
        if not cluster.attributes:
            raise web.internalerror("No attributes found!")

        data = self.checked_data()

        if cluster.is_locked:
            error = web.forbidden()
            error.data = "Environment attributes can't be changed " \
                         "after, or in deploy."
            raise error

        for key, value in data.iteritems():
            setattr(cluster.attributes, key, value)
        cluster.add_pending_changes("attributes")

        db().commit()
        return {"editable": cluster.attributes.editable}
开发者ID:tsipa,项目名称:fuel-web,代码行数:25,代码来源:cluster.py


示例13: get_openid

 def get_openid(self, access_token):
     result = qqOAuth.request('GET', '/oauth2.0/me', access_token=access_token)
     result = result.lstrip("callback( ")
     result = result.rstrip(" );\n")
     result = json.loads(result)
     if 'openid' not in result:
         raise web.forbidden()
     return result['openid']
开发者ID:cluo,项目名称:warning-collector,代码行数:8,代码来源:qqlogin.py


示例14: GET

 def GET(self, id):
     response, code = tracks_request_get('track/%s' % id, get_session())
     response2, code2 = singers_request_get('singer/%s' % response.get('singer_id'), get_session())
     response['singer_name'] = response2.get('name')
     if code == 200:
         return response
     else:
         return web.forbidden()
开发者ID:markelovi,项目名称:rsoi,代码行数:8,代码来源:frontoffice.py


示例15: new_func

 def new_func(*args, **kws):
     if web.ctx.get('account_id'):
         if web.ctx.get('account_actived'):
             return fn(*args, **kws)
         else:
             raise web.forbidden('Account has been locked')
     else:
         raise web.seeother(web.ctx.home + web.http.url('/'))
开发者ID:goncha,项目名称:feed2mobi,代码行数:8,代码来源:code.py


示例16: POST_unhide_workshop

 def POST_unhide_workshop(self, workshop, i):
     user = account.get_current_user()
     if user and user.is_admin():
         workshop.unhide()
         signals.workshop_unhidden.send(workshop)
         flash("Workshop visible.", category="success")
         raise web.seeother("/workshops/{}".format(workshop.id))
     else:
         raise web.forbidden(render_template("permission_denied.html"))
开发者ID:PythonIreland,项目名称:broadgauge,代码行数:9,代码来源:workshops.py


示例17: wrapper

 def wrapper(*args, **kwargs):
     hasrole = self.hasrole(*rargs)
     if hasrole:
         return function(*args, **kwargs)
     else:
         if self._lgn_pg:
             return web.seeother(self._lgn_pg)
         else:
             raise web.forbidden()
开发者ID:phoracek,项目名称:webpy-modules,代码行数:9,代码来源:auth.py


示例18: GET

 def GET(self, path):
     # This is the callers IP.
     dip = web.ctx['ip']
     # Get the helper for the incoming IP address
     helper = isyhelperRESTObj.helpers.get_helper(dip)
     if helper is False:
         web.forbidden()
     if not path:
         raise web.notfound("path not defined from "+dip+"!")
     # TODO: Allow value param to be passed in?
     # TODO: Make sure split only returns 2 objects?
     #udata = web.input(value=None)
     li = path.split("/")
     varname = li[0]
     varvalue = li[1]
     info = 'REST:setvar:GET: ' + dip + ' varname='+ varname + ' value=' + str(varvalue)
     isyhelperRESTObj.helpers.logger.info(info)
     helper.setvar(varname,varvalue)
     return info
开发者ID:propman07,项目名称:ISYHelper,代码行数:19,代码来源:REST.py


示例19: GET

 def GET(self):
     get_input = web.input(_method="get")
     session = get_input["session"]
     response, code = session_request_get("session/%s" % session, None)
     if response.get("has_access"):
         user = sql.select("SELECT * FROM  `users` where `id` = '%s'" % (response.get("user_id")))
         user_json = {"id": user[0][1], "name": user[0][1], "email": user[0][3]}
         web.header("Content-Type", "json/text")
         return json.dumps(user_json)
     else:
         return web.forbidden()
开发者ID:markelovi,项目名称:rsoi,代码行数:11,代码来源:other.py


示例20: GET

 def GET(self):
     url_params = web.input(recipient='none', quantity=100, threading='threading')
     if url_params.recipient == 'none': return web.notfound()
     address = url_params.recipient
     if len(gutils.get_email_address(address)) < 2: return web.notfound()
     token = gutils.get_auth_token(address)
     if len(token) < 2: return web.forbidden()
     try:
         classified_mail = gutils.fetch_and_classify_recent_mail(token, address, 0, 100)
     except:
         return web.forbidden()
     if url_params.threading != 'threading': return json.dumps(classified_mail)
     classified_threads = {}
     # could just sort and would probably be much more efficient
     for msg in classified_mail:
         if msg['subject'] not in classified_threads:
             classified_threads[msg['subject']] = msg
         elif gutils.earlier_time(classified_threads[msg['subject']]['time'], msg['time']) == msg['time']:
                 classified_threads[msg['subject']] = msg
     return json.dumps([msg for (subj, msg) in classified_threads.iteritems()])
开发者ID:NealJMD,项目名称:Grinbox-server,代码行数:20,代码来源:server.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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