[rset] Deprecate the 'encoded' argument to ResultSet.printable_rql()
It's hardly used at all, and when used inside CubicWeb, it's only set as
false. Better make sure that this function always returns a proper
unicode string and let the caller handle conversion on its own.
--- a/rset.py Wed Apr 22 09:52:28 2015 +0200
+++ b/rset.py Sun Jul 27 14:57:51 2014 +0200
@@ -21,13 +21,16 @@
from warnings import warn
+from logilab.common import nullobject
from logilab.common.decorators import cached, clear_cache, copy_cache
-
from rql import nodes, stmts
from cubicweb import NotAnEntity, NoResultError, MultipleResultsError
+_MARKER = nullobject()
+
+
class ResultSet(object):
"""A result set wraps a RQL query result. This object implements
partially the list protocol to allow direct use as a list of
@@ -362,10 +365,12 @@
rset.limited = (limit, offset)
return rset
- def printable_rql(self, encoded=False):
+ def printable_rql(self, encoded=_MARKER):
"""return the result set's origin rql as a string, with arguments
substitued
"""
+ if encoded is not _MARKER:
+ warn('[3.21] the "encoded" argument is deprecated', DeprecationWarning)
encoding = self.req.encoding
rqlstr = self.syntax_tree().as_string(encoding, self.args)
# sounds like we get encoded or unicode string due to a bug in as_string
--- a/web/views/basecomponents.py Wed Apr 22 09:52:28 2015 +0200
+++ b/web/views/basecomponents.py Sun Jul 27 14:57:51 2014 +0200
@@ -55,7 +55,7 @@
else:
rset = self.cw_rset
# display multilines query as one line
- rql = rset is not None and rset.printable_rql(encoded=False) or req.form.get('rql', '')
+ rql = rset is not None and rset.printable_rql() or req.form.get('rql', '')
rql = rql.replace(u"\n", u" ")
rql_suggestion_comp = self._cw.vreg['components'].select_or_none('rql.suggestions', self._cw)
if rql_suggestion_comp is not None: