To see if other form libraries do better I gave yafowil a try at our gocept Developer Punsch 3: yafowil comes with written documentation. To get a form in our Pyramid application I had to find out some things which are not so clearly documented:
- Let the project depend on yafowil.webob via setup.py as it contains the necessary WebOb integration.
- Import the
loaderfrom yafowil like below, to allow yafowil to register all its known components (even all the packages in the yafowil.wiget namespace). Otherwise I got strange errors. (The loader symbol is not needed at all in the rest of the code of the form.)
from yafowil import loader
- To get a value displayed in the rendered form use
valuekeyword parameter in the factory like this:
form['name'] = factory('field:label:text', props=dict(label=u'name', required=True), value=value_getter)
value can be a plain value or a function which gets the widget and the runtime data of the widget as parameters.
yafowil.base.Factory.resources_forcould be a starting point. (I did not do this yet, so it might be wrong.)
Conclusion: yafowil looks like an interesting framework and after getting a starting point it should be useable in Pyramid, too. Maybe this post can help to ease it a bit.