Hello,
How can I emulate the error handler without using a validator? For
example if a product's name is a duplicate I need to go back to the
form and have name's error text read "A product with this name already
exists."
So say I have something like this:
@expose(...)
def edit(self, **kwargs):
return dict(form=form, ...)
@expose(...)
@validate(form=form)
@error_handler(edit)
def save(self, **kwargs):
id = kwargs.get('id', None)
name = kwargs.get('name')
#Check if duplicate exists
try:
duplicateProduct = Product.byName(name):
except:
pass
else:
if duplicateProduct.id != id: #Product with same name and
different id exists
#Error here for name field, what goes here to get back to edit?
...
...
redirect("/edit", id=id)
Thanks,
-Ian
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---