__init__.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:layman 作者: CCSS-CZ 项目源码 文件源码
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()
        elif code in (501, "501", "notimplemented"):
            # web.notimplemented() # not implemented
            # TODO - set 501 code manually
            web.internalerror()

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

        return success
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号