与twisted.web 一起使用的模板和表单处理工具包
正如标题所述,我正在寻找一些东西,这将帮助我在twisted.web 中自动化表单处理(验证/渲染/等)。我也在寻找合适的模板工具包来使用它。
至于模板化,这并不是什么大问题,因为 python 中有很多库可以做到这一点。我正在考虑以下内容:
- New。嗯,它不仅仅是一个模板工具包,还有很多我可能需要或不需要的其他东西。它还可以很好地利用twisted的异步特性(据我所知,你可以用它进行增量渲染,无论这是好是坏)
- Jinja2。我还没用过,不过好像很多人都推荐它。我读过它,它似乎是一个不错的工具包。
- 原氏。与上一个
- Django的模板引擎相同。我已经用过很多次了。虽然有一些缺点,但是,它确实有效。这不是一个 django 项目,所以没有必要将自己限制在 django 的组件上。
- 天哪,理论上我可以使用 xslt 生成 xhtml (但我不会:P),因为项目处理的几乎所有数据都是 xml
至于表单处理,我必须说,我唯一熟悉的 python Web 框架是django (实际上非常熟悉它)所以我真的不知道我应该在这里考虑什么。
我知道 nevow 显然有某种内置的表单处理(称为 formless),但我不知道它有多好,而且我还没有找到任何文档(除了源代码)或使用示例(除了图例中完全微不足道的文档)。
我正在考虑的另一个选项是“栓接”django 的表单,因为这些表单并没有真正与 django 中的其他任何内容耦合,因此可以单独使用它们。不过,如果可能的话,我宁愿不这样做。
也许拥有twisted.web 项目的人可以给我一两个提示。
As the title states, I am looking for something, that will help me automate form processing (validation/rendering/etc) in twisted.web. I am also looking for a suitable templating toolkit to use with it.
As for templating, it is not so much of an issue as there are a lot of libraries in python, that do it. I was considering the following:
- Nevow. Well, it is not only a templating toolkit, but a lot of other things that I may or may not need. It also plays nice with twisted's asynchronous nature (as far as I know, you can do incremental rendering with it, whether that is good or bad)
- Jinja2. I haven't used it yet, but people seem to recommend it a lot. I've read about it and it seems to be a decent toolkit.
- Genshi. same as the previous one
- Django's templating engine. I've used it quite a lot. There are some drawbacks, but, well, it works. This is not a django project, so there is no need to restrict myself to django's components, though.
- Hell, I can theoretically generate xhtml using xslt (but I won't :P), since almost all the data the project deals with is xml
As for form processing, I must say, that the only python web framework I am familiar with is django (quite familiar with it, actually) so I don't really know what I should be considering here.
I know nevow has some kind of form processing built-in, apparently (called formless), but I have no idea how good it is and I haven't found any documentation (besides the source) or usage examples (besides the completely trivial one in the turorial).
The other option I was considering is "bolting on" django's forms, since the forms are not really coupled to anything else in django, so it is possible to use them separately. I'd rather not do it, though, if it is at all possible.
Maybe someone with an existing twisted.web project can give me a hint or two.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我真的很喜欢金贾2。它是 django 模板系统的改进形式。我在我的项目中广泛使用它。
对于表单处理,您可能需要查看 formosa。
I really like Jinja2. It's an improved form of the django templating system. I use it pretty extensively in my projects.
For form processing, you may want to check out formosa.
我对 Nevow 的体验是,在网上很难找到示例和文档。 Nevow 主页上有一些基本的链接 (http://divmod.org/trac/wiki/DivmodNevow ),但是没有什么比你在更大的 Java 框架(我更熟悉)中看到的示例和问题/答案的数量要多的了。
这似乎通过一些简单的谷歌搜索得到了证实:
我意识到这是不太科学,但它确实支持我的经验。如果我遗漏了某些内容并为我们所有人指出丰富的 Nevow(尤其是 Athena,Ajax 组件)文档来源,我将非常高兴有人能够纠正这一点...
My experience of Nevow is that examples and documentation are hard to find on the web. There are some basic ones linked from the Nevow homepage (http://divmod.org/trac/wiki/DivmodNevow), but nothing like the volume of examples and questions/asnwers you would see with the larger Java frameworks (which I am more familiar with) for example.
This seems to be borne out with some simple google searches:
I realise this is not too scientific but it does support my experience. I would be very happy for someone to correct this if I have missed something and point us all towards a rich source of Nevow (and especially Athena, the Ajax component) documentation...