cubicweb/entities/wfobjs.py
changeset 12567 26744ad37953
parent 12506 d97f9b8df92a
child 12880 59d4ad7e7df3
--- a/cubicweb/entities/wfobjs.py	Fri Apr 05 17:21:14 2019 +0200
+++ b/cubicweb/entities/wfobjs.py	Fri Apr 05 17:58:19 2019 +0200
@@ -21,12 +21,6 @@
 * workflow history (TrInfo)
 * adapter for workflowable entities (IWorkflowableAdapter)
 """
-from __future__ import print_function
-
-
-
-from six import text_type, string_types
-
 from logilab.common.decorators import cached, clear_cache
 
 from cubicweb.entities import AnyEntity, fetch_config
@@ -98,7 +92,7 @@
     def transition_by_name(self, trname):
         rset = self._cw.execute('Any T, TN WHERE T name TN, T name %(n)s, '
                                 'T transition_of WF, WF eid %(wf)s',
-                                {'n': text_type(trname), 'wf': self.eid})
+                                {'n': trname, 'wf': self.eid})
         if rset:
             return rset.get_entity(0, 0)
         return None
@@ -115,7 +109,7 @@
 
     def add_state(self, name, initial=False, **kwargs):
         """add a state to this workflow"""
-        state = self._cw.create_entity('State', name=text_type(name), **kwargs)
+        state = self._cw.create_entity('State', name=name, **kwargs)
         self._cw.execute('SET S state_of WF WHERE S eid %(s)s, WF eid %(wf)s',
                          {'s': state.eid, 'wf': self.eid})
         if initial:
@@ -127,7 +121,7 @@
 
     def _add_transition(self, trtype, name, fromstates,
                         requiredgroups=(), conditions=(), **kwargs):
-        tr = self._cw.create_entity(trtype, name=text_type(name), **kwargs)
+        tr = self._cw.create_entity(trtype, name=name, **kwargs)
         self._cw.execute('SET T transition_of WF '
                          'WHERE T eid %(t)s, WF eid %(wf)s',
                          {'t': tr.eid, 'wf': self.eid})
@@ -257,13 +251,13 @@
         for gname in requiredgroups:
             rset = self._cw.execute('SET T require_group G '
                                     'WHERE T eid %(x)s, G name %(gn)s',
-                                    {'x': self.eid, 'gn': text_type(gname)})
+                                    {'x': self.eid, 'gn': gname})
             assert rset, '%s is not a known group' % gname
-        if isinstance(conditions, string_types):
+        if isinstance(conditions, str):
             conditions = (conditions,)
         for expr in conditions:
-            if isinstance(expr, string_types):
-                kwargs = {'expr': text_type(expr)}
+            if isinstance(expr, str):
+                kwargs = {'expr': expr}
             else:
                 assert isinstance(expr, dict)
                 kwargs = expr
@@ -415,7 +409,7 @@
         """return the default workflow for entities of this type"""
         # XXX CWEType method
         wfrset = self._cw.execute('Any WF WHERE ET default_workflow WF, '
-                                  'ET name %(et)s', {'et': text_type(self.entity.cw_etype)})
+                                  'ET name %(et)s', {'et': self.entity.cw_etype})
         if wfrset:
             return wfrset.get_entity(0, 0)
         self.warning("can't find any workflow for %s", self.entity.cw_etype)
@@ -480,7 +474,7 @@
             'Any T,TT, TN WHERE S allowed_transition T, S eid %(x)s, '
             'T type TT, T type %(type)s, '
             'T name TN, T transition_of WF, WF eid %(wfeid)s',
-            {'x': self.current_state.eid, 'type': text_type(type),
+            {'x': self.current_state.eid, 'type': type,
              'wfeid': self.current_workflow.eid})
         for tr in rset.entities():
             if tr.may_be_fired(self.entity.eid):
@@ -529,7 +523,7 @@
 
     def _get_transition(self, tr):
         assert self.current_workflow
-        if isinstance(tr, string_types):
+        if isinstance(tr, str):
             _tr = self.current_workflow.transition_by_name(tr)
             assert _tr is not None, 'not a %s transition: %s' % (
                 self.__regid__, tr)