cubicweb/rset.py
changeset 12567 26744ad37953
parent 12566 6b3523f81f42
child 12931 6eae252361e5
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    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 
       
    20 
       
    21 from six import PY3, text_type
       
    22 from six.moves import range
       
    23 
    19 
    24 from logilab.common.decorators import cached, clear_cache, copy_cache
    20 from logilab.common.decorators import cached, clear_cache, copy_cache
    25 from rql import nodes, stmts
    21 from rql import nodes, stmts
    26 
    22 
    27 from cubicweb import NotAnEntity, NoResultError, MultipleResultsError, UnknownEid
    23 from cubicweb import NotAnEntity, NoResultError, MultipleResultsError, UnknownEid
   364 
   360 
   365     def printable_rql(self):
   361     def printable_rql(self):
   366         """return the result set's origin rql as a string, with arguments
   362         """return the result set's origin rql as a string, with arguments
   367         substitued
   363         substitued
   368         """
   364         """
   369         encoding = self.req.encoding
   365         return self.syntax_tree().as_string(kwargs=self.args)
   370         rqlstr = self.syntax_tree().as_string(kwargs=self.args)
       
   371         if PY3:
       
   372             return rqlstr
       
   373         if isinstance(rqlstr, text_type):
       
   374             return rqlstr
       
   375         return text_type(rqlstr, encoding)
       
   376 
   366 
   377     # client helper methods ###################################################
   367     # client helper methods ###################################################
   378 
   368 
   379     def entities(self, col=0):
   369     def entities(self, col=0):
   380         """iter on entities with eid in the `col` column of the result set"""
   370         """iter on entities with eid in the `col` column of the result set"""