avoid sanitizing warnings

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset23a2fa8cb725
branchdefault
phasepublic
hiddenno
parent revision#7dd84b69c7d4 [devtools] avoid warning about source['global-db-name']
child revision#1dcc52f5e340 [cwctl] allow overriding config settings from the command line (closes #5557656)
files modified by this revision
entities/adapters.py
entities/wfobjs.py
misc/migration/postcreate.py
server/__init__.py
server/migractions.py
server/sources/native.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1435316665 -7200
# Fri Jun 26 13:04:25 2015 +0200
# Node ID 23a2fa8cb72502b24c6673d9134d858c06558590
# Parent 7dd84b69c7d419993705a9fd9b676101785c7f96
avoid sanitizing warnings

diff --git a/entities/adapters.py b/entities/adapters.py
@@ -141,11 +141,11 @@
1          for rschema in entity.e_schema.indexable_attributes():
2              if (entity.e_schema, rschema) in pending:
3                  continue
4              weight = self.attr_weight.get(rschema, 'C')
5              try:
6 -                value = entity.printable_value(rschema, format='text/plain')
7 +                value = entity.printable_value(rschema, format=u'text/plain')
8              except TransformError:
9                  continue
10              except Exception:
11                  self.exception("can't add value of %s to text index for entity %s",
12                                 rschema, entity.eid)
diff --git a/entities/wfobjs.py b/entities/wfobjs.py
@@ -412,11 +412,11 @@
13      @cached
14      def cwetype_workflow(self):
15          """return the default workflow for entities of this type"""
16          # XXX CWEType method
17          wfrset = self._cw.execute('Any WF WHERE ET default_workflow WF, '
18 -                                  'ET name %(et)s', {'et': self.entity.cw_etype})
19 +                                  'ET name %(et)s', {'et': unicode(self.entity.cw_etype)})
20          if wfrset:
21              return wfrset.get_entity(0, 0)
22          self.warning("can't find any workflow for %s", self.entity.cw_etype)
23          return None
24 
diff --git a/misc/migration/postcreate.py b/misc/migration/postcreate.py
@@ -36,23 +36,23 @@
25  # user workflow
26  userwf = add_workflow(_('default user workflow'), 'CWUser')
27  activated = userwf.add_state(_('activated'), initial=True)
28  deactivated = userwf.add_state(_('deactivated'))
29  userwf.add_transition(_('deactivate'), (activated,), deactivated,
30 -                      requiredgroups=('managers',))
31 +                      requiredgroups=(u'managers',))
32  userwf.add_transition(_('activate'), (deactivated,), activated,
33 -                      requiredgroups=('managers',))
34 +                      requiredgroups=(u'managers',))
35 
36  # create anonymous user if all-in-one config and anonymous user has been specified
37  if hasattr(config, 'anonymous_user'):
38      anonlogin, anonpwd = config.anonymous_user()
39      if anonlogin == session.user.login:
40          print 'you are using a manager account as anonymous user.'
41          print 'Hopefully this is not a production instance...'
42      elif anonlogin:
43          from cubicweb.server import create_user
44 -        create_user(session, unicode(anonlogin), anonpwd, 'guests')
45 +        create_user(session, unicode(anonlogin), anonpwd, u'guests')
46 
47  # need this since we already have at least one user in the database (the default admin)
48  for user in rql('Any X WHERE X is CWUser').entities():
49      rql('SET X in_state S WHERE X eid %(x)s, S eid %(s)s',
50          {'x': user.eid, 's': activated.eid})
@@ -61,11 +61,11 @@
51  if interactive_mode:
52      cfg = config.persistent_options_configuration()
53      cfg.input_config(inputlevel=0)
54      for section, options in cfg.options_by_section():
55          for optname, optdict, value in options:
56 -            key = '%s.%s' % (section, optname)
57 +            key = u'%s.%s' % (section, optname)
58              default = cfg.option_default(optname, optdict)
59              # only record values differing from default
60              if value != default:
61                  rql('INSERT CWProperty X: X pkey %(k)s, X value %(v)s',
62                      {'k': key, 'v': value})
diff --git a/server/__init__.py b/server/__init__.py
@@ -278,11 +278,11 @@
63              else:
64                  login, pwd = unicode(source['db-user']), source['db-password']
65          # sort for eid predicatability as expected in some server tests
66          for group in sorted(BASE_GROUPS):
67              cnx.create_entity('CWGroup', name=unicode(group))
68 -        admin = create_user(cnx, login, pwd, 'managers')
69 +        admin = create_user(cnx, login, pwd, u'managers')
70          cnx.execute('SET X owned_by U WHERE X is IN (CWGroup,CWSource), U eid %(u)s',
71                          {'u': admin.eid})
72          cnx.commit()
73      repo.shutdown()
74      # reloging using the admin user
diff --git a/server/migractions.py b/server/migractions.py
@@ -1274,10 +1274,11 @@
75              wfof = (wfof,)
76          def _missing_wf_rel(etype):
77              return 'missing workflow relations, see make_workflowable(%s)' % etype
78          for etype in wfof:
79              eschema = self.repo.schema[etype]
80 +            etype = unicode(etype)
81              if ensure_workflowable:
82                  assert 'in_state' in eschema.subjrels, _missing_wf_rel(etype)
83                  assert 'custom_workflow' in eschema.subjrels, _missing_wf_rel(etype)
84                  assert 'wf_info_for' in eschema.objrels, _missing_wf_rel(etype)
85              rset = self.rqlexec(
diff --git a/server/sources/native.py b/server/sources/native.py
@@ -895,11 +895,11 @@
86          assert cnx.cnxset is not None
87          # begin by inserting eid/type/source/extid into the entities table
88          if extid is not None:
89              assert isinstance(extid, str)
90              extid = b64encode(extid)
91 -        attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': extid and unicode(extid),
92 +        attrs = {'type': unicode(entity.cw_etype), 'eid': entity.eid, 'extid': extid and unicode(extid),
93                   'asource': unicode(source.uri)}
94          self._handle_insert_entity_sql(cnx, self.sqlgen.insert('entities', attrs), attrs)
95          # insert core relations: is, is_instance_of and cw_source
96          try:
97              self._handle_is_relation_sql(cnx, 'INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)',