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):
        return 'Your integer was: ' + str(integerplease)

templates/plainform.html:
-----------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:py="http://genshi.edgewall.org/";
      xmlns:xi="http://www.w3.org/2001/XInclude";>

<xi:include href="master.html" />

<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type"
py:replace="''"/>
</head>

<body>
    ${form(value=kw)}
</body>
</html>

Everything else is unchanged from the quickstart.

<debugging blather, feel free to ignore unless you're trying to root out a bug>
>From what I can tell, DecoratedController._handle_validation_errors in
decorated.py ought to do something with exception besides stashing two
pieces of it in pylons.c, where it seems to be ignored.  I even got
*part* of this working by a huge hack - in root.py, I can import
pylons, get pylons.c.form_values, then use that as the value my form
gets called with, and my old values won't vanish when the form
re-renders after failing validation.  The same approach won't work for
displaying error messages, though.  I tried reading
pylons.c.form_errors and passing that to the form as "error" looked
like it would work, but
toscawidgets/widgets/forms/InputWidget/propagate_errors expects
"error" to include attributes like .error_dict, when
pylons.c.form_errors is just a simple dict - I think it wants the
originally raised exception, which was discarded by
_handle_validation_errors.  And, anyway, that's obviously not the way
it's *supposed* to go.
</debugging blather>

Thanks,
-- 
- Catherine
http://catherinedevlin.blogspot.com/
*** PyCon 2008 * Chicago * March 13-20 * us.pycon.org ***

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to