带有金字塔的 sprox 的 hello world [英] The hello world of sprox with pyramid
问题描述
我尝试使用金字塔在 Sprox 中构建最简单的形式.
I've tried to build the simplest possible form in Sprox using pyramid.
# model.py
class Allocation:
# some fields ...
class SproxForm(AddRecordForm):
__model__ = Allocation
sprox_form = SproxForm(DBSession)
<小时>
# views.py
def sprox_form(request):
return {'f':sprox_form,'kw':{}}
<小时>
<html>
<body>
<div tal:content="structure f(kw)"/>
</body>
</html>
但它只是打印出 {'kw': {}, 'f': }
表单教程 是使用 TurboGears2 编写的,我无法将其翻译成金字塔,因为我是金字塔的新手.
But it just prints out {'kw': {}, 'f': }
The forms tutorial is written using TurboGears2 and I am unable to translate it to pyramid, because I am new to pyramid.
那么有人可以告诉我我做错了什么,或者向我展示一个使用金字塔的简短(但完整)示例?
So could someone tell me what am I doing wrong, or show me a short (but complete) example, which uses pyramid?
推荐答案
好吧,您的表单名为 sprox_form
,而您的视图名为 sprox_form
.这种模糊性将是一个坏主意.除此之外,我看不出任何可疑之处,假设您的变色龙语法是正确的.如果您使用的是 mako,则它只是 ${f(kw)}
虽然不是 f
我可能建议使用名称 widget
或form
,而不是 kw
可能是 value
或 form_input
.
Well your form is named sprox_form
and your view is named sprox_form
. This ambiguity is gonna be a bad idea. Other than that I can't see anything suspicious, assuming your chameleon syntax is correct. If you were using mako it'd be simply ${f(kw)}
although instead of f
I might suggest using the name widget
or form
, and instead of kw
maybe value
or form_input
.
这篇关于带有金字塔的 sprox 的 hello world的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!