ancient.model --- 存储模型的目录


response

class ancient.model.response.DateEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[源代码]

基类:json.encoder.JSONEncoder

default(obj)[源代码]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class ancient.model.response.ResponseModel[源代码]

基类:object

响应模型,通过实例化该类并调用该类的get方法获取返回的json格式数据 注意,采用ResponseModel类即意味着你将不遵循restful风格规范,而 采用madtornado风格的接口规范:

响应码:200[使用madtornado风格的接口规范,需保证任何状态http码都为200,通过返回数据的status进行状态标记]
返回类型示例:{"status": "fail", "description": "not found", "message": ""}
static dumps(data, encode_date=False)[源代码]

json.dumps的别名,用于方便调用

参数:
  • data -- 需要解析的数据对象
  • encode_date -- 对象中是否存在date或datetime对象
返回:

str

get(encode_date=False)[源代码]

通过改写ResponseModel实例的get方法返回值,实现全局的默认返回格式

参数:encode_date --
返回:str