问题标签 [colander]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
269 浏览

python - 使用变形的相关/级联输入

我正在尝试使用 Deform / Colander / Chameleon / Pyramid 进行一系列相关输入,但找不到任何示例。例如

收益率下拉Country列表->

Stateor Provinceor Division..etc的下拉菜单。产量->

Countyor ...的下拉菜单City可能会产生->

下拉City...

这可以使用变形来完成吗?(如果不能,我应该看看另一种生成表单的解决方案还是去纯 html/javascript/ajax/..?)

我将其简化为地理划分。我宁愿在加载表单时只发送 1200 万条记录数据库中必要的部分,并随着选择的增加而逐渐缩小。

这是 Deform 示例页面的链接:http: //deformdemo.repoze.org/select_with_deferred/

0 投票
1 回答
87 浏览

pyramid - 使用 shape.widget.FileUploadWidget 设置最大上传大小

如果文件太大,如何使用 shape.widget.FileUploadWidget() 限制最大上传大小,以便验证失败并显示友好的错误消息?

0 投票
2 回答
173 浏览

python-3.x - 如何在漏勺中翻译错误信息

如何翻译滤锅验证器的错误消息?文档只是说这是可能的。

我知道变形已经做到了,但我需要自己使用滤锅

0 投票
1 回答
645 浏览

deform - 在 Colander 和 Deform 中创建映射模式序列

我正在构建一个页面,用户可以在其中对 Colander 和 Deform 中的任意数量的产品进行评论。我已经掌握了所有必需的元素,但我仍然有一些连接点的问题。具体来说,我如何强制(动态地)创建 N 个表单项的序列,然后为它们绑定数据?

这是我到目前为止的尝试:

但这会导致错误:

0 投票
1 回答
124 浏览

pyramid - 带有两个选项卡的变形 2/滤锅模式甚至无法验证

尝试为变形 2、滤锅 1.0 制作一个带有两个选项卡(命令式)的表单。表单的想法是在手动添加网页及其标题之间进行选择,或者选择一个提要 URL:

在表单控制器(金字塔)中:

虽然控件似乎有数据:

appstruct 为空:

尝试了标题,缺失,默认,未知参数,没有结果。表格有什么问题?

此外,不是两个选项卡,而是两个后续字段集,但这可能是另一回事。

0 投票
2 回答
268 浏览

python - 使用 Pyramid 在视图和应用程序之间共享对象

我正在尝试使用 Pyramid 为数据分析管道创建一个 Web 界面。我正在使用变形和滤锅制作表格。我一直在调整这个例子:

http://pyramid-tutorials.readthedocs.org/en/latest/humans/security/step02/

提交表单后,大部分工作就完成了,但是有几个通用步骤只需要运行一次。我可以在服务器启动时将一些东西加载到内存中,以便可以从视图中访问它们吗?

0 投票
0 回答
86 浏览

python - 如何使用滤锅/变形(金字塔)的形式传输不可编辑的数据

我有一小部分表格。第一个接受两个字段,一个记录 ID 和一个机构 ID,它们需要作为静态信息传递到下一个表单,但需要与第二个表单中的其余数据一起传递,然后使用两个表单中的数据做真正的工作。我已将第一个标记为 readonly=true,另一个是我通过 javascript 禁用的选择。当我单击“提交”时,两者都返回缺少的验证错误。

这样做的滤锅方法是什么?我希望这些值在表单上可见,所以 hiddenfield 不太正确。

0 投票
1 回答
566 浏览

python - 在滤锅 SchemaNode 中处理经过验证的数据

我在 API 中有一组与 Pyramid/Cornice 一起使用的滤锅 SchemaNode。对于某些查询字符串参数,传递一个范围(即time=X-Y表示从 X 到 Y 的时间范围,其中 X 和 Y 是表示时期的整数)。我目前使用验证器对此进行RegEx()验证,以确保传入一个纪元或纪元范围:

然后我在 MappingSchema 中使用它,然后将其绑定到我的 Cornice 视图@view(schema=TimedThingGet)

我想做的是更新我的TimeOrRangeSchemaNode 代码中的返回值,所以timeinTimedThingGet是时间范围的元组。换句话说,如果time=X-Y传递给TimedThingGet实例,则time=(x, y)在验证数据中返回。同样,如果只X传入,那么我想Y设置为now().

看起来set_value()是要走的路,这就是问题得到一些额外功劳的地方:

  1. set_value是在验证之前还是之后被调用?
  2. 是否set_value有权访问验证器,以便RegEx可以使用创建正则表达式组的验证器来设置我的元组:time=(validated.match.group[1], validated.match.group[2])
0 投票
1 回答
687 浏览

validation - pyramid/cornice validators and colander schema

I have a cornice API with a view that has validators and a colander schema. I can't get access to colander validated data (request.validated) in my validator.

I pass my data through colander. My colander schema looks something like this:

It adds a sanitized version of the request data into request.validated['user'] that I can then access in my view like this.

However, I also need to check that the request provides a unique username and return an error if the username is already taken. I'd like to do this with a validator (valid_new_username) but when I try to access request.validated['user'] in my validator the data aren't there.

It looks like the validator is called before the data have been extracted. I don't really want to access the request json_body data directly before passing them through colander. Is there a way I can change the ordering of the schema/validator?

The alternative is to do the checking directly in my view callable. Is that a good option? Are validators not supposed to work with colander validated data?

0 投票
1 回答
996 浏览

python - 如何在滤锅表单中使用列表或数组

如何以 POST 形式发送列表/数组并使用滤锅对其进行解码?我已经尝试了几种方法,但到目前为止没有运气。使用如下形式的表单和滤锅架构将引发错误:[1,2,3] is not iterable

示例_1.html:

示例_1.py:

而这种其他方法根本行不通,因为我们无法创建名为ids[].

示例_2.html:

有没有办法做到这一点?