rset.py
branchstable
changeset 5747 d6ac0cd30fde
parent 5740 46207f491a51
child 5752 b0bb553e3be4
equal deleted inserted replaced
5746:f4fc424747db 5747:d6ac0cd30fde
    42       result's description, using the same structure as the result itself
    42       result's description, using the same structure as the result itself
    43 
    43 
    44     :type rql: str or unicode
    44     :type rql: str or unicode
    45     :param rql: the original RQL query string
    45     :param rql: the original RQL query string
    46     """
    46     """
    47     _picklable_attributes = set(['limited', 'rows', 'description', '_rsetactions',
       
    48                                  'args', 'rowcount', '_rqlst', 'rql'])
       
    49 
    47 
    50     def __init__(self, results, rql, args=None, description=(), rqlst=None):
    48     def __init__(self, results, rql, args=None, description=(), rqlst=None):
    51         self.rows = results
    49         self.rows = results
    52         self.rowcount = results and len(results) or 0
    50         self.rowcount = results and len(results) or 0
    53         # original query and arguments
    51         # original query and arguments
   117         return self.rows[i:j]
   115         return self.rows[i:j]
   118 
   116 
   119     def __iter__(self):
   117     def __iter__(self):
   120         """Returns an iterator over rows"""
   118         """Returns an iterator over rows"""
   121         return iter(self.rows)
   119         return iter(self.rows)
   122 
       
   123     def __getstate__(self):
       
   124         return dict((k, v) for k, v in self.__dict__.iteritems()
       
   125                     if k in self._picklable_attributes)
       
   126 
   120 
   127     def __add__(self, rset):
   121     def __add__(self, rset):
   128         # XXX buggy implementation (.rql and .args attributes at least much
   122         # XXX buggy implementation (.rql and .args attributes at least much
   129         # probably differ)
   123         # probably differ)
   130         # at least rql could be fixed now that we have union and sub-queries
   124         # at least rql could be fixed now that we have union and sub-queries