web/views/autoform.py
changeset 3503 06bced8edddf
parent 3485 e867ae952fc0
parent 3470 c9c8b231db7b
child 3505 c0c7a944c00d
--- a/web/views/autoform.py	Sat Sep 26 11:44:35 2009 +0200
+++ b/web/views/autoform.py	Mon Sep 28 12:37:01 2009 +0200
@@ -111,6 +111,11 @@
     @property
     def form_needs_multipart(self):
         """true if the form needs enctype=multipart/form-data"""
+        return self._subform_needs_multipart()
+
+    def _subform_needs_multipart(self, _tested=None):
+        if _tested is None:
+            _tested = set()
         if super(AutomaticEntityForm, self).form_needs_multipart:
             return True
         # take a look at inlined forms to check (recursively) if they
@@ -129,11 +134,18 @@
             if len(targettypes) != 1:
                 continue
             targettype = targettypes[0]
+            if targettype in _tested:
+                continue
+            _tested.add(targettype)
             if self.should_inline_relation_form(rschema, targettype, role):
                 entity = self._cw.vreg['etypes'].etype_class(targettype)(self._cw)
                 subform = self._cw.vreg['forms'].select('edition', self._cw,
                                                         entity=entity)
-                if subform.form_needs_multipart:
+                if hasattr(subform, '_subform_needs_multipart'):
+                    needs_multipart = subform._subform_needs_multipart(_tested)
+                else:
+                    needs_multipart = subform.form_needs_multipart
+                if needs_multipart:
                     return True
         return False