Updated AJAX form decorator
authorThierry Florac <thierry.florac@onf.fr>
Tue, 09 Oct 2018 11:48:27 +0200
changeset 149 d26223a00c51
parent 148 3ab9784d19f0
child 150 f78d1b46e03c
Updated AJAX form decorator
src/pyams_form/form.py
--- a/src/pyams_form/form.py	Fri Oct 05 15:07:46 2018 +0200
+++ b/src/pyams_form/form.py	Tue Oct 09 11:48:27 2018 +0200
@@ -728,13 +728,14 @@
             try:
                 # check if current form is overriding "get_ajax_output" method
                 if base not in (AJAXAddForm, AJAXEditForm):  # custom base
-                    basename = base.__qualname__
-                    baseklassname, _ = base.get_ajax_output.__qualname__.split('.')
-                    if baseklassname != basename:  # overriden method
-                        new_class.get_ajax_output = ob.get_ajax_output
+                    ob_ajax_parent, _ = ob.get_ajax_output.__qualname__.split('.')
+                    base_ajax_parent, _ = base.get_ajax_output.__qualname__.split('.')
+                    if (ob_ajax_parent != base_ajax_parent) and \
+                       (ob_ajax_parent in ('AJAXForm', 'AJAXAddForm', 'AJAXEditForm')):
+                            new_class.get_ajax_output = base.get_ajax_output
                 else:
-                    baseklassname, _ = ob.get_ajax_output.__qualname__.split('.')
-                    if baseklassname not in ('AJAXForm', 'AJAXEditForm'):  # overriden method
+                    base_ajax_parent, _ = ob.get_ajax_output.__qualname__.split('.')
+                    if base_ajax_parent not in ('AJAXForm', 'AJAXAddForm', 'AJAXEditForm'):  # overriden method
                         new_class.get_ajax_output = ob.get_ajax_output
             except AttributeError:
                 pass