190 return self.maxrelitems + 1 |
190 return self.maxrelitems + 1 |
191 |
191 |
192 @property |
192 @property |
193 def form_needs_multipart(self): |
193 def form_needs_multipart(self): |
194 """true if the form needs enctype=multipart/form-data""" |
194 """true if the form needs enctype=multipart/form-data""" |
|
195 return self._subform_needs_multipart() |
|
196 |
|
197 def _subform_needs_multipart(self, _tested=None): |
|
198 if _tested is None: |
|
199 _tested = set() |
195 if super(AutomaticEntityForm, self).form_needs_multipart: |
200 if super(AutomaticEntityForm, self).form_needs_multipart: |
196 return True |
201 return True |
197 # take a look at inlined forms to check (recursively) if they |
202 # take a look at inlined forms to check (recursively) if they |
198 # need multipart handling. |
203 # need multipart handling. |
199 # XXX: this is very suboptimal because inlined forms will be |
204 # XXX: this is very suboptimal because inlined forms will be |
208 for rschema, targettypes, role in self.inlined_relations(): |
213 for rschema, targettypes, role in self.inlined_relations(): |
209 # inlined forms don't handle multiple target types |
214 # inlined forms don't handle multiple target types |
210 if len(targettypes) != 1: |
215 if len(targettypes) != 1: |
211 continue |
216 continue |
212 targettype = targettypes[0] |
217 targettype = targettypes[0] |
|
218 if targettype in _tested: |
|
219 continue |
|
220 _tested.add(targettype) |
213 if self.should_inline_relation_form(rschema, targettype, role): |
221 if self.should_inline_relation_form(rschema, targettype, role): |
214 entity = self.vreg['etypes'].etype_class(targettype)(self.req) |
222 entity = self.vreg['etypes'].etype_class(targettype)(self.req) |
215 subform = self.vreg['forms'].select('edition', self.req, entity=entity) |
223 subform = self.vreg['forms'].select('edition', self.req, entity=entity) |
216 if subform.form_needs_multipart: |
224 if hasattr(subform, '_subform_needs_multipart'): |
|
225 needs_multipart = subform._subform_needs_multipart(_tested) |
|
226 else: |
|
227 needs_multipart = subform.form_needs_multipart |
|
228 if needs_multipart: |
217 return True |
229 return True |
218 return False |
230 return False |
219 |
231 |
220 def action(self): |
232 def action(self): |
221 """return the form's action attribute. Default to validateform if not |
233 """return the form's action attribute. Default to validateform if not |