don't use rset.rowcount in predicates, this makes them usable with other types such as lists stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 30 Aug 2012 17:38:43 +0200
branchstable
changeset 8528 f32c50c6b7e0
parent 8527 6151b0199bc1
child 8529 1daea1f433c9
don't use rset.rowcount in predicates, this makes them usable with other types such as lists
predicates.py
--- a/predicates.py	Thu Aug 30 17:11:05 2012 +0200
+++ b/predicates.py	Thu Aug 30 17:38:43 2012 +0200
@@ -558,7 +558,7 @@
 @objectify_predicate
 def nonempty_rset(cls, req, rset=None, **kwargs):
     """Return 1 for result set containing one ore more rows."""
-    if rset is not None and rset.rowcount:
+    if rset:
         return 1
     return 0
 
@@ -567,7 +567,7 @@
 @objectify_predicate
 def empty_rset(cls, req, rset=None, **kwargs):
     """Return 1 for result set which doesn't contain any row."""
-    if rset is not None and rset.rowcount == 0:
+    if rset is not None and len(rset) == 0:
         return 1
     return 0
 
@@ -580,7 +580,7 @@
     """
     if rset is None and 'entity' in kwargs:
         return 1
-    if rset is not None and (row is not None or rset.rowcount == 1):
+    if rset is not None and (row is not None or len(rset) == 1):
         return 1
     return 0
 
@@ -608,7 +608,7 @@
         return self.operator(num, self.expected)
 
     def __call__(self, cls, req, rset=None, **kwargs):
-        return int(rset is not None and self.match_expected(rset.rowcount))
+        return int(rset is not None and self.match_expected(len(rset)))
 
 
 class multi_columns_rset(multi_lines_rset):
@@ -648,7 +648,7 @@
                 page_size = req.property_value('navigation.page-size')
             else:
                 page_size = int(page_size)
-        if rset.rowcount <= (page_size*self.nbpages):
+        if len(rset) <= (page_size*self.nbpages):
             return 0
         return self.nbpages