Checkout this example:
http://lucasmanual.com/mywiki/TurboGears#head-6d455a03efb936498f708a1bcd6efeee9f5c9401
comments inline.
On Jan 21, 2008 2:08 PM, Catherine Devlin <[EMAIL PROTECTED]> wrote:
>
> On Jan 18, 2008 10:31 AM, percious <[EMAIL PROTECTED]> wrote:
> >
> > try putting **kw in the argument list and then passing kw into the
> > widget as the value.
>
> Thank you... still nothing, though. **kw comes in empty.
>
> Here's an absolute bare-bones version that duplicates the error. If
> nobody can see anything I'm doing wrong, I'll file it as a bug.
>
> controllers/root.py:
> ----------------------------------------------------
> from val.lib.base import BaseController
> from toscawidgets.widgets import forms
> from formencode import validators
> from toscawidgets.api import WidgetsList
> from tg import validate, expose
>
> class MyFields(WidgetsList):
> integerplease = forms.TextField(validator=validators.Int())
>
> myForm = forms.TableForm(fields=MyFields(), action='acknowledge')
>
> class RootController(BaseController):
>
> @expose(template='val.templates.plainform')
> def ask(self, tg_errors=None, **kwargs):
> return {'form': myForm, 'kw': kwargs}
>
> @expose()
> @validate(validators=myForm.validator, error_handler=ask)
> def acknowledge(self, integerplease):
shouldn't this be :
def acknowledge(self, **kwargs):
return 'Your integer was: ' + str(kwargs['integerplease'])
also action should be something like '/acknowlage'. This is how you pass a form:
@expose(template="addressbook.templates.form")
def addressbook(self):
submit_action = "/addressbookprocess"
return dict(form=addressbook_form,action=submit_action)
and receive a form:
@expose()
@error_handler(addressbook)
@validate(form=addressbook_form)
def addressbookprocess(self,**kwargs):
return dict(kwargs=kwargs)
template:
<body>
${form(action=action)}
</body>
not sure how much things changed in 2.0, but this code works in 1.*
Lucas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---