Thanks,
- jmj
Cheers,
--
Soni Bergraj
Widgets by default work thusly:
top_form = TableForm(name="top_form", widgets=(
TextField(name="alpha"),
TextField(name="bravo"),
TextField(name="charlie"))
...in an exposed method...
return dict(
data = {'alpha':1,'bravo':2,'charlie':3},
form = top_form,
)
...in your template...
${form.insert(data)}
The data is expected to be a class with attributes matching the names
in the form, but if you pass in a dict with the correct keys it gets
converted. The names in the data and on the text fields have to match.
Especially now that the plugins are no longer tied to TurboGears or
CherryPy, it would be nice for its maintenance to move elsewhere...
Kevin
--
Kevin Dangoor
Author of the Zesty News RSS newsreader
email: k...@blazingthings.com
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com
Hi,
I just took at a look at the ticket... Here's the explanation:
Yep. This is currently expected behavior. You can get around this by:
1. adding your template name to turbogears.view.baseTemplates.
2. calling turbogears.view.loadBaseTemplates()
This is all a matter of the fact that the template has not been
loaded/converted to Python. If you precompile your templates, it would
likely work.
Kevin
> I just took at a look at the ticket... Here's the explanation:
> Yep. This is currently expected behavior. You can get around this by:
>
> 1. adding your template name to turbogears.view.baseTemplates.
> 2. calling turbogears.view.loadBaseTemplates()
I added those two lines to my controllers.py:
turbogears.view.baseTemplates.append("cheetah:wiktory.templates.master")
turbogears.view.loadBaseTemplates()
but i still get the attached traceback.
> This is all a matter of the fact that the template has not been
> loaded/converted to Python. If you precompile your templates, it would
> likely work.
I'm working with precompiled templates. Do not precompiled templates
work at all?
Any ideas?
Thanks,
--
Soni Bergraj
I wasn't clear enough, I think. Try extending wiktory.templates.master
in your Cheetah template.
Kevin
An
#extends myproject.templates.master
instead of an
#extends master
finally works. And it is an amazingly 20 times faster than the kid
solution;)
Thanks for the hint:)
--
Soni Bergraj
This still does not work for me. I'm currently using revision 514.
Have there been any further developments on this since r514?
Lee
What does not work for you? Passing a dict?
Kevin
Yes, passing a dict does not work.
I have the following code (just to make sure it wasn't my controller
code messing things up)
<span py:replace="forwardform.insert(input_values={'fwd_msgid':
message.id, 'forward_to': ''}, action='/messages/%d/forward' %
message.id)"></span>
for the following widget:
forwardform = widgets.TableForm(widgets=[
widgets.TextField(name="forward_to",
labeltext="Forward To", validator=validators.Email()),
customwidgets.Hidden(name="fwd_msgid",
validator=validators.Int())],
submittext="Forward")
The widgets in customwidgets are the same but have custom templates.
I get no VALUE parameter in the resulting hidden field in the page.
I've tested this with more complex forms with the standard widgets
with the same result. The value is always omitted.
Try getting rid of the "inpuit_values=". If you pass the form widget a
dictionary as its value, that should get applied.
Kevin