backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 26 May 2010 15:46:27 +0200
changeset 5594 fe7d84363d23
parent 5591 c6edefa9b3f1 (current diff)
parent 5593 f6c55bec9326 (diff)
child 5595 d179e8229642
backport stable
web/views/autoform.py
--- a/server/sources/rql2sql.py	Wed May 26 14:37:32 2010 +0200
+++ b/server/sources/rql2sql.py	Wed May 26 15:46:27 2010 +0200
@@ -1177,13 +1177,26 @@
             pass
         return ''
 
+    def _temp_table_scope(self, select, table):
+        scope = 9999
+        for var, sql in self._varmap.iteritems():
+            if table == sql.split('.', 1)[0]:
+                try:
+                    scope = min(scope, self._state.scopes[select.defined_vars[var].scope])
+                except KeyError:
+                    scope = 0 # XXX
+                if scope == 0:
+                    return 0
+        return 0
+
     def _var_info(self, var):
-        scope = self._state.scopes[var.scope]
         try:
             sql = self._varmap[var.name]
             tablealias = sql.split('.', 1)[0]
+            scope = self._temp_table_scope(var.stmt, tablealias)
             self.add_table(tablealias, scope=scope)
         except KeyError:
+            scope = self._state.scopes[var.scope]
             etype = self._state.solution[var.name]
             # XXX this check should be moved in rql.stcheck
             if self.schema.eschema(etype).final:
--- a/web/views/autoform.py	Wed May 26 14:37:32 2010 +0200
+++ b/web/views/autoform.py	Wed May 26 15:46:27 2010 +0200
@@ -125,6 +125,7 @@
 
 from logilab.mtconverter import xml_escape
 from logilab.common.decorators import iclassmethod, cached
+from logilab.common.deprecation import deprecated
 
 from cubicweb import typed_eid, neg_role, uilib
 from cubicweb.schema import display_name
@@ -646,6 +647,18 @@
     # action on the form tag
     _default_form_action_path = 'validateform'
 
+    # pre 3.8.3 compat
+    @property
+    def set_action(self, action):
+        self._action = action
+    @deprecated('[3.9] use form.form_action()')
+    def get_action(self):
+        try:
+            return self._action
+        except AttributeError:
+            return self._cw.build_url(self._default_form_action_path)
+    action = property(get_action, set_action)
+
     @iclassmethod
     def field_by_name(cls_or_self, name, role=None, eschema=None):
         """return field with the given name and role. If field is not explicitly