[Zope3-Users] Hook into edit-form post
Marco Mariani
marco at sferacarta.com
Mon Jul 10 18:10:08 EDT 2006
On Sun, Jul 09, 2006 at 10:47:42AM -0700, Siddhartha Azad wrote:
> It updates fine, but I want the update to go through a
> ZPT or some block of code once I press the "Change"
> button (do the POST).
>
> Do you know if that is possible?
"go through ZPT" as in "redirect to another page"?
if so, you should override nextURL:
def nextURL(self):
return "whatever.html"
Or, if "go though some block of code" means pre-processing the data you
got, you could do something like:
def handle_edit_action_failure(self, action, data, errors):
self.status = 'There have been %d errors.' % len(errors)
@form.action("Button Label", failure='handle_edit_action_failure')
def handle_edit_action(self, action, data):
....preprocessing here...
if form.applyChanges(self.context, self.form_fields, data):
notify(ObjectModifiedEvent(self.context))
....postprocessing here...
self.status = 'Object has been updated'
else:
self.status = 'Nothing happened'
More information about the Zope3-users
mailing list