Hi Jason,

this discussion really belgons to tg-trunk, anyway...

Jason Chu wrote:
> We're working with our own existing code base with a bunch of custom
> widget changes, so hopefully this still applies.
>
> I have a problem with form validation.  We create custom forms all the
> time, because we want to have a better layout than the TableForm or
> ListForm.
>
> One such form contains something that extends SelectionField.  This widget
> needs its list of options when it's instantiated (it's possible to do it
> later, but you'd have to pass it its own validator...).  The list of
> options for the widget is taken from the current user, so we have to
> generate the form at request time, not before.  To use this form for
> validation, we pass it to the validate decorator as a class, not an
> instance.
>

Can you explain better (on tg-trunk) why you need to use a new instance
for every request? I think the problem is this and that there is a way
to do it with just a instance.

> Some recent changes went in, including the can_access_request (base.py)
> function that looks at the widget's path and sees if the widgets above it
> are the same as the validated_form.  In our case, it is not.
>

Yep, that's the change I've done to support more than one form in the
same page, we discussed about it on tg-trunk yesterday...

> I narrowed it down to the controllers.py file, line 108.  If the validate
> decorator is passed something that is callable and not a widget, it will
> instatiate it.  The problem is that it passes 'self' as the first
> parameter.  The first parameter to a form is its name, so the
> validated_form gets a name of my controller instance.
>
> I'm pretty lost at this point.  I don't know which direction the widgets
> are supposed to be going so that we can continue to steer ourselves that
> way.
>

Widgets are only getting some internal polish lately, we always try to
not break anything in existing code, this thing has break because I
think you're using the wrong solution for your problem, generating a
new form on the fly is not the way widgets are supposed to work, I
think we can find the right solution together on tg-trunk. ;-)

Ciao
Michele


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to