Howdy!

Is there a way to have a single controller both produce the form and validate it (taking appropriate action as needed)?  I.e. I want to have the following, but if I try it always assigns errors to my empty (not-yet-submitted) form...

@expose(template="myapp.templates.genericform")
@validate(forms.signup)
def signup(self, tg_errors=None, **kw):
if tg_errors is True:
turbogears.flash("error::" + _("There were errors processing your request."))
elif tg_errors is False:
transaction = M.hub.begin()
try:
# Create account, sign in, and send confirmation e-mail.
pass
except:
transaction.rollback()
raise

transaction.commit()
turbogears.flash("success::" + _("Success message!"))
turbogears.redirect("/")
data = "">
data.update(**kw)
data['password']['first'] = ""
data['password']['second'] = ""

return dict(
title=_("Create Account"),
description=_("Enter your information below to get started."),
form=forms.signup,
action="">
data="">
)

I'd expect tg_errors to remain None if the form hasn't even been submitted yet.  Even simply having a hidden field or GET argument, say _trigger, which the validate decorator looks for before attempting validation would be good.

Matthew Bevan, Systems Administrator
Top Floor Computer Systems Ltd.



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