Howdy!
In my case I have a form like so:
modifyForm = CustomForm(
widgets = [
W.Hidden("action", default="update"),
W.TextField("Title", default=None, validator=V.String(),
description="..."),
W.TextArea("Description", default=None, attrs={'rows': 3},
description="..."),
W.SelectField("DefaultView", labeltext="Default View",
default=None,
options=[...],
description="..."),
W.SelectField("DefaultAtom", labeltext="Default Atom",
default=None,
options=[],
description="..."),
],
submittext = "Update"
)
In my controller, my _modify method provides the current node (node) and the
form (form) to Kid.
node = content.model.Folder.get(self.id)
return dict(controller=self, node=node, form=modifyForm, args=kwargs)
In KID, I have the following:
<span py:replace="form.insert(node, action=controller.path+'_modify')"
/>
Now, I want to use one method (_modify) to do the original display, error
display, and final processing of this form. To this end I added the hidden
field at the top. How can I test for this hidden value then process the
form?
The @turbogears.expose(inputform=...) method doesn't work due to my use of
relative template paths. I fixed this problem in my decorators by mirroring
the decorated callable's __module__ magic variable, though I can't seem to
make an effective similar change to the TG controller.py decorators. I
continue to get the attached traceback if I attempt to use inputform in the
expose decorator.
There is currently very little documentation regarding Widgets. ;^P By the
end of my nightmare, I hope to write some.
- Matthew
Traceback (most recent call last):
File
"/usr/lib64/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py",
line 271, in run
main()
File
"/usr/lib64/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py",
line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
File
"/usr/lib64/python2.4/site-packages/TurboGears-0.9a0dev_r503-py2.4.egg/turbogears/controllers.py",
line 240, in newfunc
html, fragment, *args, **kw)
File
"/usr/lib64/python2.4/site-packages/TurboGears-0.9a0dev_r503-py2.4.egg/turbogears/database.py",
line 189, in run_with_transaction
retval = func(*args, **kw)
File
"/usr/lib64/python2.4/site-packages/TurboGears-0.9a0dev_r503-py2.4.egg/turbogears/controllers.py",
line 262, in _execute_func
return _process_output(tg_format, output, html, fragment)
File
"/usr/lib64/python2.4/site-packages/TurboGears-0.9a0dev_r503-py2.4.egg/turbogears/controllers.py",
line 62, in _process_output
output = view.render(output, tg_format, template=template,fragment=fragment)
File
"/usr/lib64/python2.4/site-packages/TurboGears-0.9a0dev_r503-py2.4.egg/turbogears/view.py",
line 57, in render
return engine.render(info, format, fragment, template)
File
"/usr/lib64/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 122, in render
tclass = self.load_template(template)
File
"/usr/lib64/python2.4/site-packages/TurboKid-0.9.0-py2.4.egg/turbokid/kidsupport.py",
line 94, in load_template
"%s.kid" % basename)
File
"/usr/lib64/python2.4/site-packages/setuptools-0.6a9-py2.4.egg/pkg_resources.py",
line 676, in resource_filename
return get_provider(package_or_requirement).get_resource_filename(
File
"/usr/lib64/python2.4/site-packages/setuptools-0.6a9-py2.4.egg/pkg_resources.py",
line 119, in get_provider
__import__(moduleOrReq)
ImportError: No module named templates