merge and prepare 0.26.3 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Jun 2010 09:51:52 +0200
branchstable
changeset 565 d3013b4f134c
parent 564 c933fb01dbe2 (current diff)
parent 563 ba03d9f51737 (diff)
child 566 7fb422fc2032
merge and prepare 0.26.3
ChangeLog
__pkginfo__.py
debian/changelog
setup.py
stmts.py
--- a/ChangeLog	Fri Jun 18 09:40:09 2010 +0200
+++ b/ChangeLog	Mon Jun 21 09:51:52 2010 +0200
@@ -3,6 +3,8 @@
 
 	--
     * support for node from having in Select.remove
+    * enhanced Select.replace method
+    * rql st checker now checks function avaibility according to backend (if specified)
 
 2010-06-11  --  0.26.2
     * totally remove 'IS' operator
--- a/__init__.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/__init__.py	Mon Jun 21 09:51:52 2010 +0200
@@ -38,7 +38,7 @@
       - comparison of two queries
     """
     def __init__(self, schema, uid_func_mapping=None, special_relations=None,
-                 resolver_class=None):
+                 resolver_class=None, backend=None):
         # chech schema
         #for e_type in REQUIRED_TYPES:
         #    if not schema.has_entity(e_type):
@@ -49,7 +49,7 @@
         if uid_func_mapping:
             for key in uid_func_mapping:
                 special_relations[key] = 'uid'
-        self._checker = RQLSTChecker(schema, special_relations)
+        self._checker = RQLSTChecker(schema, special_relations, backend)
         self._annotator = RQLSTAnnotator(schema, special_relations)
         self._analyser_lock = threading.Lock()
         if resolver_class is None:
@@ -76,6 +76,12 @@
         self._annotator.schema = schema
         self._analyser.set_schema(schema)
 
+    def get_backend(self):
+        return self._checker.backend
+    def set_backend(self, backend):
+        self._checker.backend = backend
+    backend = property(get_backend, set_backend)
+
     def parse(self, rqlstring, annotate=True):
         """Return a syntax tree created from a RQL string."""
         rqlst = parse(rqlstring, False)
--- a/__pkginfo__.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/__pkginfo__.py	Mon Jun 21 09:51:52 2010 +0200
@@ -20,7 +20,7 @@
 __docformat__ = "restructuredtext en"
 
 modname = "rql"
-numversion = (0, 26, 2)
+numversion = (0, 26, 3)
 version = '.'.join(str(num) for num in numversion)
 
 license = 'LGPL'
@@ -28,7 +28,7 @@
 author = "Logilab"
 author_email = "contact@logilab.fr"
 
-short_desc = "relationship query language (RQL) utilities"
+description = "relationship query language (RQL) utilities"
 long_desc = """A library providing the base utilities to handle RQL queries,
 such as a parser, a type inferencer.
 """
--- a/base.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/base.py	Mon Jun 21 09:51:52 2010 +0200
@@ -18,8 +18,8 @@
 """Base classes for RQL syntax tree nodes.
 
 Note: this module uses __slots__ to limit memory usage.
+"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 class BaseNode(object):
--- a/debian/changelog	Fri Jun 18 09:40:09 2010 +0200
+++ b/debian/changelog	Mon Jun 21 09:51:52 2010 +0200
@@ -1,3 +1,9 @@
+rql (0.26.3-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Mon, 21 Jun 2010 09:34:41 +0200
+
 rql (0.26.2-1) unstable; urgency=low
 
   * new upstream release
--- a/editextensions.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/editextensions.py	Mon Jun 21 09:51:52 2010 +0200
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with rql. If not, see <http://www.gnu.org/licenses/>.
-"""RQL functions for manipulating syntax trees.
+"""RQL functions for manipulating syntax trees."""
 
-"""
 __docformat__ = "restructuredtext en"
 
 from rql.nodes import Constant, Variable, VariableRef, Relation, make_relation
--- a/setup.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/setup.py	Mon Jun 21 09:51:52 2010 +0200
@@ -40,7 +40,7 @@
 
 sys.modules.pop('__pkginfo__', None)
 # import required features
-from __pkginfo__ import modname, version, license, short_desc, long_desc, \
+from __pkginfo__ import modname, version, license, description, long_desc, \
      web, author, author_email
 # import optional features
 import __pkginfo__
@@ -185,7 +185,7 @@
     return setup(name = distname,
                  version = version,
                  license = license,
-                 description = short_desc,
+                 description = description,
                  long_description = long_desc,
                  author = author,
                  author_email = author_email,
--- a/stcheck.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/stcheck.py	Mon Jun 21 09:51:52 2010 +0200
@@ -80,9 +80,10 @@
     errors due to a bad rql input
     """
 
-    def __init__(self, schema, special_relations=None):
+    def __init__(self, schema, special_relations=None, backend=None):
         self.schema = schema
         self.special_relations = special_relations or {}
+        self.backend = backend
 
     def check(self, node):
         state = STCheckState()
@@ -417,6 +418,11 @@
                 funcdescr.check_nbargs(len(function.children))
             except BadRQLQuery, ex:
                 state.error(str(ex))
+            if self.backend is not None:
+                try:
+                    funcdescr.st_check_backend(self.backend, function)
+                except BadRQLQuery, ex:
+                    state.error(str(ex))
             if funcdescr.aggregat:
                 if isinstance(function.children[0], Function) and \
                        function.children[0].descr().aggregat:
--- a/stmts.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/stmts.py	Mon Jun 21 09:51:52 2010 +0200
@@ -19,8 +19,8 @@
 
 This module defines only first level nodes (i.e. statements). Child nodes are
 defined in the nodes module
+"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 from copy import deepcopy
@@ -398,7 +398,7 @@
     # select clauses
     groupby = ()
     orderby = ()
-    having = ()
+    having = () # XXX now a single node
     with_ = ()
     # set by the annotator
     has_aggregat = False
@@ -681,16 +681,23 @@
     # * undo support
     # * references handling
     def replace(self, oldnode, newnode):
-        assert oldnode is self.where
-        self.where = newnode
+        if oldnode is self.where:
+            self.where = newnode
+        elif oldnode in self.selection:
+            self.selection[self.selection.index(oldnode)] = newnode
+        elif oldnode in self.orderby:
+            self.orderby[self.orderby.index(oldnode)] = newnode
+        elif oldnode in self.groupby:
+            self.groupby[self.groupby.index(oldnode)] = newnode
+        elif oldnode in self.having:
+            self.having[self.having.index(oldnode)] = newnode
+        else:
+            raise Exception('duh XXX %s' % oldnode)
+        # XXX no undo/reference support 'by design' (eg breaks things if you add
+        # it...)
+        # XXX resetting oldnode parent cause pb with cw.test_views (w/ facets)
+        #oldnode.parent = None
         newnode.parent = self
-#         # XXX no vref handling ?
-#         try:
-#             Statement.replace(self, oldnode, newnode)
-#         except ValueError:
-#             i = self.selection.index(oldnode)
-#             self.selection.pop(i)
-#             self.selection.insert(i, newnode)
 
     def remove(self, node):
         if node is self.where:
--- a/utils.py	Fri Jun 18 09:40:09 2010 +0200
+++ b/utils.py	Mon Jun 21 09:51:52 2010 +0200
@@ -15,11 +15,12 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with rql. If not, see <http://www.gnu.org/licenses/>.
-"""Miscellaneous utilities for RQL.
+"""Miscellaneous utilities for RQL."""
 
-"""
 __docformat__ = "restructuredtext en"
 
+from rql._exceptions import BadRQLQuery
+
 UPPERCASE = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 def decompose_b26(index, table=UPPERCASE):
     """Return a letter (base-26) decomposition of index."""
@@ -78,6 +79,12 @@
         ', '.join(sorted(child.get_description(mainindex, tr)
                          for child in iter_funcnode_variables(funcnode))))
 
+@monkeypatch(FunctionDescr)
+def st_check_backend(self, backend, funcnode):
+    if not self.supports(backend):
+        raise BadRQLQuery("backend %s doesn't support function %s" % (backend, self.name))
+
+
 def iter_funcnode_variables(funcnode):
     for term in funcnode.children:
         try: