Are you using widgets to handle your forms? If so, try setting your
error handler to the original function. Your previous example would
look something like this:
@expose(template="xxxxx")
def edit(self, userId, tg_errors=None):
if tg_errors:
**handle error notification. see below for link to details***
user = UserServices.getById(userId)
return dict(user = user)
@expose()
@error_handler(edit)
@validate(...
def save(...
The only change you need to make to your 'edit' controller is that it
has to accept a tg_errors parameter. If anything fails validation
tg_errors will be a dictionary of validators.Invalid objects with the
field names as keys. More info here:
http://docs.turbogears.org/1.0/ValidateDecorator
The advantage to doing it this way is that, the form is pre-populated
with the original data, provided you are using widgets to generate the
form. If not you should be able to scrape the data you want out of
tg_errors, but I have yet to see any good reason besides personal
preference to not use widgets for this.
-Adam
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---