rset.py
changeset 10691 af266f27c4d5
parent 10687 d394bfcd8c25
child 10903 da30851f9706
equal deleted inserted replaced
10690:c6290d727c0c 10691:af266f27c4d5
    14 # details.
    14 # details.
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """The `ResultSet` class which is returned as result of an rql query"""
    18 """The `ResultSet` class which is returned as result of an rql query"""
    19 
    19 from __future__ import print_function
    20 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    21 
    21 
    22 from warnings import warn
    22 from warnings import warn
    23 
    23 
    24 from six import PY3
    24 from six import PY3
   119         """returns the result set's size"""
   119         """returns the result set's size"""
   120         return self.rowcount
   120         return self.rowcount
   121 
   121 
   122     def __getitem__(self, i):
   122     def __getitem__(self, i):
   123         """returns the ith element of the result set"""
   123         """returns the ith element of the result set"""
       
   124         #print('__getitem__', i)
   124         return self.rows[i] #ResultSetRow(self.rows[i])
   125         return self.rows[i] #ResultSetRow(self.rows[i])
   125 
       
   126     def __getslice__(self, i, j):
       
   127         """returns slice [i:j] of the result set"""
       
   128         return self.rows[i:j]
       
   129 
   126 
   130     def __iter__(self):
   127     def __iter__(self):
   131         """Returns an iterator over rows"""
   128         """Returns an iterator over rows"""
   132         return iter(self.rows)
   129         return iter(self.rows)
   133 
   130