eve - 架构中的默认值(客户端 IP)

标签 eve

有没有办法将客户端 IP 作为我的架构中的默认值?7

我已经在配置部分查看了 python-eve.org 主页,但我找不到任何东西;(

谢谢 哈拉尔德

最佳答案

目前default仅接受静态值。计划支持可调用函数和 lambda。实际上,此时此刻有一个待处理的拉取请求等待合并。

在那之前,您可能可以使用回调函数来实现您的有效负载。像这样的东西:

from flask import request

def before_insert(resource_name, documents):
    if resource_name == 'myresource':
        for document in documents:
            document['field'] = request.remote_addr

app = Eve()
app.on_insert += before_insert

app.run()

关于eve - 架构中的默认值(客户端 IP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35295554/

相关文章:

python - python-eve 在 POST 操作中删除查找参数的原因是什么?

python - 我可以在 python-eve 中指定位置并同时聚合吗?

Python Eve patch_internal设置etag

python - 如何更改单个文档值的架构类型

python - 使用服务器发送的事件浏览器缓存以前的数据。如何防止浏览器缓存

python - 仅使用 python-eve API 向 MongoDB 请求 `_items`

python - 如何在自定义EVE route 编写模型

python - 使用 Python Eve 添加 mongoDB 文档数组元素

python - Python Eve 中的双层嵌入

python - 使用 python eve 使用 put_internal 上传文件