[web] unicode → six.text_type
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 30 Sep 2015 18:04:27 +0200
changeset 10740 59e89db3a67d
parent 10739 27f946cfe350
child 10741 6666e52d8dd9
[web] unicode → six.text_type
web/application.py
web/views/basecontrollers.py
web/views/schema.py
--- a/web/application.py	Wed Sep 30 18:03:53 2015 +0200
+++ b/web/application.py	Wed Sep 30 18:04:27 2015 +0200
@@ -25,6 +25,7 @@
 from warnings import warn
 import json
 
+from six import text_type
 from six.moves import http_client
 
 from logilab.common.deprecation import deprecated
@@ -80,8 +81,8 @@
 
     def reset_session_manager(self):
         data = self.session_manager.dump_data()
-        self.session_manager = self.vreg['components'].select('sessionmanager',
-                                                              repo=self.repo)
+        self.session_manager = self.vreg['sessions'].select('sessionmanager',
+                                                            repo=self.repo)
         self.session_manager.restore_data(data)
         global SESSION_MANAGER
         SESSION_MANAGER = self.session_manager
@@ -497,7 +498,7 @@
         if req.status_out < 400:
             # don't overwrite it if it's already set
             req.status_out = status
-        json_dumper = getattr(ex, 'dumps', lambda : json.dumps({'reason': unicode(ex)}))
+        json_dumper = getattr(ex, 'dumps', lambda : json.dumps({'reason': text_type(ex)}))
         return json_dumper()
 
     # special case handling
--- a/web/views/basecontrollers.py	Wed Sep 30 18:03:53 2015 +0200
+++ b/web/views/basecontrollers.py	Wed Sep 30 18:04:27 2015 +0200
@@ -24,6 +24,8 @@
 
 from warnings import warn
 
+from six import text_type
+
 from logilab.common.deprecation import deprecated
 
 from cubicweb import (NoSelectableObject, ObjectNotFound, ValidationError,
@@ -233,7 +235,7 @@
     except Exception as ex:
         req.cnx.rollback()
         req.exception('unexpected error while validating form')
-        return (False, str(ex).decode('utf-8'), ctrl._edited_entity)
+        return (False, text_type(ex), ctrl._edited_entity)
     return (False, '???', None)
 
 
--- a/web/views/schema.py	Wed Sep 30 18:03:53 2015 +0200
+++ b/web/views/schema.py	Wed Sep 30 18:04:27 2015 +0200
@@ -26,6 +26,8 @@
 import os, os.path as osp
 import codecs
 
+from six import text_type
+
 from logilab.common.graph import GraphGenerator, DotBackend
 from logilab.common.ureports import Section, Table
 from logilab.common.registry import yes
@@ -279,7 +281,7 @@
     def cell_call(self, row, col):
         defaultval = self.cw_rset.rows[row][col]
         if defaultval is not None:
-            self.w(unicode(self.cw_rset.rows[row][col].unzpickle()))
+            self.w(text_type(self.cw_rset.rows[row][col].unzpickle()))
 
 class CWETypeRelationCardinalityCell(baseviews.FinalView):
     __regid__ = 'etype-rel-cardinality-cell'
@@ -487,7 +489,7 @@
         entity = self.cw_rset.get_entity(row, col)
         rschema = self._cw.vreg.schema.rschema(entity.rtype.name)
         rdef = rschema.rdefs[(entity.stype.name, entity.otype.name)]
-        constraints = [xml_escape(unicode(c)) for c in getattr(rdef, 'constraints')]
+        constraints = [xml_escape(text_type(c)) for c in getattr(rdef, 'constraints')]
         self.w(u'<br/>'.join(constraints))
 
 class CWAttributeOptionsCell(EntityView):