Flask-RESTful Documentation Release 0.3.10} Custom Fields & Multiple Values Sometimes you have your own custom formatting needs. You can subclass the fields.Raw class and implement the format function. This is especially useful when an attribute output formatting without having to modify your internal objects directly. All you have to do is subclass Raw and implement the format() method: class AllCapsString(fields.Raw): def format(self, value): code) resp.headers.extend(headers or {}) return resp Another way to accomplish this is to subclass the Api class and provide your own output functions. class Api(restful.Api): def __init__(self0 码力 | 42 页 | 84.60 KB | 1 年前3
Click Documentation
Release 4.2.dev0parameter is called dest. 1.4.4 Implementing Custom Types To implement a custom type, you need to subclass the ParamType class. Types can be invoked with or without context and parameter object, which is is not a valid integer' % value, param, ctx) BASED_INT = BasedIntParamType() As you can see, a subclass needs to implement the ParamType.convert() method and optionally provide the ParamType.name attribute merate the aliases on the help page in order to avoid confusion. This following example implements a subclass of Group that accepts a prefix for a command. If there were a com- mand called push, it would accept0 码力 | 101 页 | 407.32 KB | 1 年前3
共 2 条
- 1













