web/views/autoform.py
branchstable
changeset 3470 c9c8b231db7b
parent 3360 b02df886eb3e
child 3503 06bced8edddf
child 3518 11ce4682187d
--- a/web/views/autoform.py	Wed Sep 23 18:23:52 2009 +0200
+++ b/web/views/autoform.py	Fri Sep 25 11:01:23 2009 +0200
@@ -192,6 +192,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
@@ -210,10 +215,17 @@
             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.vreg['etypes'].etype_class(targettype)(self.req)
                 subform = self.vreg['forms'].select('edition', self.req, 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