Skip to content

Instantly share code, notes, and snippets.

@ale-rt
Created November 19, 2015 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ale-rt/fac9a94ed2c3bfbf9f19 to your computer and use it in GitHub Desktop.
Save ale-rt/fac9a94ed2c3bfbf9f19 to your computer and use it in GitHub Desktop.
Dexterity example: override nextURL
class BaseEditForm(DefaultEditForm):
def nextURL(self):
''' Try to guess in a smart way what will bethe next url
'''
next_url = super(BaseEditForm, self).nextURL()
current_tab = getattr(self, 'tab_id', '')
if not current_tab:
return next_url
if not current_tab in self.wizard_tabs:
return next_url
current_index = self.wizard_tabs.index(current_tab)
if getattr(self.context, '%s_compiled' % current_tab, False):
#project is already compiled, and we return to the view
return next_url
if current_index == len(self.wizard_tabs) - 1:
return next_url
return "%s/@@%s" % (
self.context.absolute_url(),
self.wizard_tabs[current_index + 1]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment