fif inlined relation forms pb w/ new ajax forms.
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 26 Jan 2010 13:36:55 +0100
changeset 4366 d51f28ba9399
parent 4365 e2d26ff8f13b
child 4367 fa02f7dccfe4
fif inlined relation forms pb w/ new ajax forms. We've to ensure the varmaker is properly initialized when generating a form where we may add new subentities, which will use ajax call to generate the subform while this subform expect a varmaker to be set.
web/request.py
web/views/editforms.py
--- a/web/request.py	Tue Jan 26 13:34:12 2010 +0100
+++ b/web/request.py	Tue Jan 26 13:36:55 2010 +0100
@@ -103,6 +103,17 @@
 
     @property
     def varmaker(self):
+        """the rql varmaker is exposed both as a property and as the
+        set_varmaker function since we've two use cases:
+
+        * accessing the req.varmaker property to get a new variable name
+
+        * calling req.set_varmaker() to ensure a varmaker is set for later ajax
+          calls sharing our .pageid
+        """
+        return self.set_varmaker()
+
+    def set_varmaker(self):
         varmaker = self.get_page_data('rql_varmaker')
         if varmaker is None:
             varmaker = rqlvar_maker()
--- a/web/views/editforms.py	Tue Jan 26 13:34:12 2010 +0100
+++ b/web/views/editforms.py	Tue Jan 26 13:36:55 2010 +0100
@@ -590,6 +590,7 @@
     form = None # no actual form wrapped
 
     def call(self, i18nctx, **kwargs):
+        self._cw.set_varmaker()
         divid = "addNew%s%s%s:%s" % (self.etype, self.rtype, self.role, self.peid)
         self.w(u'<div class="inlinedform" id="%s" cubicweb:limit="true">'
           % divid)