我无法创建API以JSON格式返回datefields。所以我必须创建一个函数来序列化它。dump_datetime函数可以帮我完成这个任务。 我现在的问题是,每当我抛出GET resource请求时,我不知道如何让我的资源调用运行dump_datetime调用。在
假设有一个资源用户具有“birthdate”属性。如何使“birthdate”属性通过dump_datetime()函数?在
Since in Eve you could already get the item call by http://127.0.0.1:5000/users/id
如何设置get调用以通过dump_datetime?在
我的问题清楚了吗?在
下面是一个使用我创建的反序列化函数的自定义函数的示例。我只想知道如何在Eve项目和资源调用中使用它。在
^{pr2}$更新: 我应该编辑/var/www/healthyoptions middleware/eve/methods吗/获取.py对需要序列化的属性执行序列化函数?????在
如果我理解你的要求,你只需要使用事件钩子。GET方法上的post请求钩子和您想要的资源应该可以完成这个任务;例如
on_post_GET_<resource_name> = deserializing_function
。或者,您也可以挂接数据库请求,例如在提取的资源上。在根据文件:
http://python-eve.org/features.html#event-hooks
相关问题 更多 >
编程相关推荐