Commit a0827af0 authored by Vincent Pelletier's avatar Vincent Pelletier

Make proxyfield's WidgetDelegatedMethod lazily retrieve proxyfied method's...

Make proxyfield's WidgetDelegatedMethod lazily retrieve proxyfied method's func_code, so that it's easier to pinpoint underlying method.
Use case: when a widget rendering method raises and the rendered field is a proxyfield, func_code cans be read *after* call raised.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21956 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0115306e
...@@ -63,6 +63,8 @@ def purgeFieldValueCache(): ...@@ -63,6 +63,8 @@ def purgeFieldValueCache():
class WidgetDelegatedMethod(Method): class WidgetDelegatedMethod(Method):
"""Method delegated to the proxied field's widget. """Method delegated to the proxied field's widget.
""" """
func_code = None
def __init__(self, method_id, default=''): def __init__(self, method_id, default=''):
self._method_id = method_id self._method_id = method_id
self._default = default self._default = default
...@@ -72,7 +74,10 @@ class WidgetDelegatedMethod(Method): ...@@ -72,7 +74,10 @@ class WidgetDelegatedMethod(Method):
proxied_field = field.getRecursiveTemplateField() proxied_field = field.getRecursiveTemplateField()
if proxied_field: if proxied_field:
proxied_method = getattr(proxied_field.widget, self._method_id) proxied_method = getattr(proxied_field.widget, self._method_id)
return proxied_method(field, *args, **kw) try:
return proxied_method(field, *args, **kw)
finally:
self.func_code = getattr(proxied_method, 'func_code', None)
return self._default return self._default
......
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