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

Python web.ok函数代码示例

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

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



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

示例1: PUT

    def PUT(self):
        ctx = readPlistFromString(web.data())
        status = ctx.get("Status")
        UDID = ctx.get("UDID")
        g_cmd_queue = MDMDB("./mdm.db")
        g_cmd_queue.open()
        cmdinfo = g_cmd_queue.getCommandInfo(UDID=UDID)
        if not cmdinfo:
            g_cmd_queue.close()
            return web.ok()

        cmd_status = int(cmdinfo["Status"])
        print cmd_status
        if cmd_status == 0:
            plist = getCommandPlist(cmdinfo["Command"], args=cmdinfo["Arguments"])
            g_cmd_queue.setCommandStatus(UDID=UDID, status=1)
            g_cmd_queue.close()
            return plist
        elif cmd_status == 1:
            print ctx
            # TODO:Add code here to check device status.
            g_cmd_queue.removeCommand(UDID=UDID)
            g_cmd_queue.close()
            return web.ok()
        else:
            return web.unauthorized
开发者ID:Jameszjhe,项目名称:Py-MDM-iOS,代码行数:26,代码来源:MDMServer.py


示例2: _setReturnCode

    def _setReturnCode(self, code):
        """Set the return code

        :param: code
        :type code: integer or string
        returns success: [True|False]
        """
        success = False

        if code in (200, "200", "ok"):
            web.ok()
            success = True
        elif code in (201, "201", "created"):
            web.created()
            success = True
        elif code in (400, "400", "badrequest"):
            web.badrequest()
        elif code in (401, "401", "unauthorized"):
            web.unauthorized()
        elif code in (404, "404", "notfound"):
            web.notfound()
        elif code in (409, "409", "conflict"):
            web.conflict()
        elif code in (500, "500", "internalerror"):
            web.internalerror()

        if success:
            logging.debug("[LayMan][_setReturnCode] Code: '%s'" % code)
        else:
            logging.error("[LayMan][_setReturnCode] Code: '%s'" % code)

        return success
开发者ID:riskatlas,项目名称:layman,代码行数:32,代码来源:__init__.py


示例3: DELETE

    def DELETE(self, resource):
        """
        Try to delete the supplied resource
        """
        if isTestMode():  # check env. if in test mode, import dbconn mock
            import Shared

            dbConn = Shared.dbMock
        else:
            dbConn = DataAccessLayer.DataAccessLayer()

        if not isValidKey(resource):
            logging.info("Item-DELETE: invalid resource key (%s)", resource)
            web.badrequest()
            return

        try:
            dbConn.delete(resource)
        except AttributeError:
            logging.warning("Item-DELETE: unable to delete resource (%s)", resource)
            web.notfound()
            return
        except Exception as e:
            logging.error("Item-DELETE: Unexpected exception when deleting: %s", e)
            web.badrequest()
            return
        web.ok()
        return
开发者ID:OttoDeLupe,项目名称:ThingsToDo,代码行数:28,代码来源:BizLayer.py


示例4: PUT

    def PUT(self, slug):
        entry = db.entries.find_one({'slug': slug})

        if not entry:
            raise web.notfound()
        else:
            updated_entry = objectify.fromstring(web.data())
            db.entries.update({'_id': entry['_id'],},{
                'slug': slug,
                'title': updated_entry.title.text,
                'updated': datetime.datetime.now(),
                'author': updated_entry.author.name.text,
                'content': updated_entry.content.text,
            })
            body = xmlify(db.entries.find_one({'slug': slug}), web.home)

            web.header(
                'Content-Type',
                'application/atom+xml;type=entry;charset="utf-8"'
                )
            web.header(
                'Content-Length',
                len(body)
                )
            
            raise web.ok(body)
开发者ID:freudenberg,项目名称:atomicblog,代码行数:26,代码来源:atom.py


示例5: success

 def success(self, i):
     if i.redirect_url:
         url = self.build_url(i.redirect_url, status="ok")
         return web.seeother(url)
     else:
         d = json.dumps({ "status" : "ok" })
         return web.ok(d, {"Content-type": "application/json"})
开发者ID:lukasklein,项目名称:openlibrary,代码行数:7,代码来源:code.py


示例6: GET

 def GET(self):
     type = web.input().get('type', '')
     if type == 'atom':
         out = render.atomfeed(web.ctx.home)
     else:
         out = render.rssfeed(web.ctx.home)
     raise web.ok(out)
开发者ID:anandology,项目名称:kottapalli,代码行数:7,代码来源:code.py


示例7: __call__

 def __call__(self, handler):
     if web.ctx.path.startswith("/api/") or web.ctx.path.endswith(".json"):
         self.add_cors_headers()
     if web.ctx.method == "OPTIONS":
         raise web.ok("")
     else:
         return handler()
开发者ID:ahvigil,项目名称:openlibrary,代码行数:7,代码来源:processors.py


示例8: POST

 def POST(self):
     x = web.input()
     if x.has_key("id"):
         if not s.exists(x['id']):
             item = s.get_item(x['id'])
             raise web.created()
         else:
             raise web.ok()
开发者ID:benosteen,项目名称:SiloServer,代码行数:8,代码来源:dropbox.py


示例9: GET

 def GET(self, slug):
     media = Media.get(slug)
     if media:
         web.ok(
             {
                 "Expires": "Thu, 15 Apr 3010 20:00:00 GMT",
                 "Cache-Control": "max-age=3600,public",
                 "Content-Type": str(media.mtype),
             }
         )
         a = web.input(a="")["a"]
         if a and a.lower() == "download":
             media.download += 1
             media.put()
         return media.bits
     else:
         return web.notfound()
开发者ID:hellolibo,项目名称:pyblog,代码行数:17,代码来源:views.py


示例10: POST

 def POST(self):
     global last_snapshot
     i = web.input()
     if last_snapshot is not None:
         tweeter.tweet_photo(str(datetime.now()), last_snapshot['blob'])
         # tweeter.tweet('test')
     print i
     return web.ok()
开发者ID:marc-hanheide,项目名称:window_draw,代码行数:8,代码来源:app.py


示例11: GET

    def GET(self, method=None):
        # Default is to turn something on
        if method == 'on' or not method:
            self._d.turn_on()
            return web.ok()

        if method == 'off':
            self._d.turn_off()
            return web.ok()

        # TODO: Test this so it doesn't clash with the web.input() call in 
        # __init__()
        if method == 'parameter':
            query = web.input(
                parameter = None,
                value = ''
            )

            if not query.parameter:
                raise web.badrequest()

            try:
                value = self._d.get_parameter(parameter)
            except:
                raise web.internalerror()

            if not value:
                raise web.notfound()

            return json.dumps(dict(
                parameter = parameter,
                value = value
            ))

        if method == 'model':
            model = self._d.model
            if not model:
                raise web.notfound()

        if method == 'learn':
            try:
                self._d.learn()
            except(td.TDDeviceError), e:
                web.internalerror()
                return json.dumps(dict(error=str(e)))
            return web.ok()
开发者ID:stemid,项目名称:kraft,代码行数:46,代码来源:api.py


示例12: GET

 def GET(self):
     if last_snapshot is None:
         return web.ok()
     else:
         web.header('Content-Type', 'image/png')  # file type
         # web.header('Content-disposition',
         #            'attachment; filename=graphotti.png')
         return last_snapshot['blob']
开发者ID:marc-hanheide,项目名称:window_draw,代码行数:8,代码来源:app.py


示例13: DELETE

    def DELETE(self, uuid=None):

        if uuid is None:
            raise web.badrequest()

        # @throws web.notfound
        self.handler.delete(uuid)

        raise web.ok()
开发者ID:kchr,项目名称:birdlist,代码行数:9,代码来源:controller.py


示例14: POST

 def POST(self):
     variables = web.input()
     if (variables.get('username') == configuration.web_user()) & (variables.get('password') == configuration.web_pwd()):
         user_session.login = 1
         print 'Logged in.'
         return web.ok()           
     else:
         user_session.login = 0
         return web.unauthorized()          
开发者ID:tnanakou,项目名称:chestfreezer,代码行数:9,代码来源:chestfreezer_api.py


示例15: GET

 def GET(self):
     web.header('Access-Control-Allow-Origin', '*')
     params = web.input()
     if 'user' not in params or 'pass' not in params:
         return web.badrequest()
     if random.choice([True, False]):
         return web.ok()
     else:
         return web.unauthorized()
开发者ID:splodingsocks,项目名称:Loginator,代码行数:9,代码来源:login.py


示例16: GET

    def GET(self, uuid=None):

        if uuid is None:
            data = self.handler.get_list()
        else:
            # @throws web.notfound
            data = self.handler.get(uuid)

        raise web.ok(self.dump_json(data))
开发者ID:kchr,项目名称:birdlist,代码行数:9,代码来源:controller.py


示例17: POST

    def POST(self):
        form = self.form()
        if not form.validates():
            return render.reset(form)

        try:
            user_id = users.get_user(form.d.username).id
        except AttributeError:
            raise web.BadRequest('user does not exist')
        else:
            users.change_password(user_id, form.d.password)
            raise web.ok('password has been reset')
开发者ID:csdms,项目名称:wmt,代码行数:12,代码来源:account.py


示例18: DELETE

    def DELETE( self, entityType, localID, remoteID, testdata = None  ):
        """
        delete an object
        """
        if testdata == None:
            self._nocache()
        
        entity = self._getEntity( entityType, localID, remoteID )

        if entity:
            entity.delete()
            return web.ok()
        else:
            return web.notfound()
开发者ID:boldstelvis,项目名称:shotgun-replica,代码行数:14,代码来源:server.py


示例19: get_user

 def get_user(self):
     i = web.input(token=None)
     if i.token:
         user = Person.find_from_reset_token(i.token)
         if not user:
             form = forms.ChangePasswordForm()
             raise web.ok(render.change_password(user, form))
         else:
             return user
     else:
         user = account.get_current_user()
         if not user:
             raise web.seeother("/account/login")
         else:
             return user
开发者ID:anandology,项目名称:voternet,代码行数:15,代码来源:webapp.py


示例20: POST

 def POST(self):
     '''
     Uses input from the image table and the csapi to delete an image.
     '''
     image = web.input()
     
     token = web.cookies().get('token')
     tenant_id = web.cookies().get('tenant_id')
     
     headers = { "X-Auth-Token": token, "X-Auth-Tenant-ID": tenant_id }
     response = util.APIRequest(util.csapi_ip, util.csapi_port, util.csapi_root+"/image/v1/images/"+image.id, "DELETE", None, headers)
     if response:
         return web.ok()
     else:
         return web.BadRequest()
开发者ID:lixmgl,项目名称:Intern_OpenStack_Swift,代码行数:15,代码来源:image.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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