Commit a4c87dac authored by Nitish Rathi's avatar Nitish Rathi

swallow TypeError only if related to compatibility

Handling TypeError in _on_model_change without any additional checking for the cause causes an extremely puzzling error message in case a TypeError is raised by the code in on_model_change. Checking the error's message to see if it's actually caused by incompatible on_model_change signature give more readable error message and trace when the TypeError is caused by the user's code.
parent 09678c05
...@@ -1164,12 +1164,15 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -1164,12 +1164,15 @@ class BaseModelView(BaseView, ActionsMixin):
""" """
try: try:
self.on_model_change(form, model, is_created) self.on_model_change(form, model, is_created)
except TypeError: except TypeError, e:
msg = ('%s.on_model_change() now accepts third ' + if e.message == 'on_model_change() takes exactly 3 arguments (4 given)':
'parameter is_created. Please update your code') % self.model msg = ('%s.on_model_change() now accepts third ' +
warnings.warn(msg) 'parameter is_created. Please update your code') % self.model
warnings.warn(msg)
self.on_model_change(form, model) self.on_model_change(form, model)
else:
raise
def after_model_change(self, form, model, is_created): def after_model_change(self, form, model, is_created):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment