# HG changeset patch # User Sylvain Thénault # Date 1254919015 -7200 # Node ID c5b40ab4ea43d3374b16c0127f5b2899653f06fa # Parent 987232bd79cd510e2ed00da029902679e83e6692 rewrite form_needs_multipart using precomputed form views diff -r 987232bd79cd -r c5b40ab4ea43 web/views/autoform.py --- a/web/views/autoform.py Wed Oct 07 14:36:19 2009 +0200 +++ b/web/views/autoform.py Wed Oct 07 14:36:55 2009 +0200 @@ -215,21 +215,12 @@ # -> generate the
node when the content is rendered # and we know the correct enctype (formrenderer's w attribute # is not a StringIO) - for rschema, targettypes, role in self.inlined_relations(): - # inlined forms don't handle multiple target types - 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 hasattr(subform, '_subform_needs_multipart'): - needs_multipart = subform._subform_needs_multipart(_tested) + for formview in self.inlined_form_views(): + if formview.form: + if hasattr(formview.form, '_subform_needs_multipart'): + needs_multipart = formview.form._subform_needs_multipart(_tested) else: - needs_multipart = subform.form_needs_multipart + needs_multipart = formview.form.form_needs_multipart if needs_multipart: return True return False