The hello world of sprox with pyramid

对着背影说爱祢 提交于 2019-12-25 02:24:50

问题


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>

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?


回答1:


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.



来源:https://stackoverflow.com/questions/14419400/the-hello-world-of-sprox-with-pyramid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!