Is there another way to validate a TableForm Widget without
declaring/defining it structure outside the Root class (or any class
for that matter) ?

-------------------------

For example:

(From http://docs.turbogears.org/1.0/ErrorHandling )

from turbogears import controllers, expose, redirect
from turbogears import validate, validators as v
from turbogears import error_handler
from turbogears import widgets as w

number_form = w.ListForm(
    fields = [
        w.TextField(
            name="number",
            label="Enter a Number",
            validator=v.Int(not_empty=True))
    ],
    submit_text = "Submit Number!"
)

## This is what the template looks like
# <html xmlns:py="http://purl.org/kid/ns#";>
#     <body>
#         <h1>This is a Form Page!</h1>
#         ${form(value_of('data',None), action=action, method="POST")}
#     </body>
# </html>

class Root(controllers.RootController):

    @expose(template=".templates.welcome")
    def index(self,number=-1,tg_errors=None):
        return dict(data={'number':number},
                    form=number_form,
                    action="/validated_number")

    @expose()
    @error_handler(index)
    @validate(form=number_form)
    def validated_number(self, number=2):
        return dict(valid_number=number)

-------------------------

Here number_form is declared/defined outside the Root class. Wouldn't
it be great if its defined inside the index method? I know that if I do
that, the @validate decorator tag can't find the number_form. So, is
there another way to do this? Because I just can't imagine to declare
and define every and each one of my forms outside the Root (or any )
class. Or is this the correct/standard way to do this?

thanx in advanced !!!

--
miya


--~--~---------~--~----~------------~-------~--~----~
 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to