entities/wfobjs.py
changeset 3536 f6c9a5df80fb
parent 3458 b7621175989a
parent 3528 77a69de16709
child 3589 a5432f99f2d9
--- a/entities/wfobjs.py	Tue Sep 29 15:58:44 2009 +0200
+++ b/entities/wfobjs.py	Wed Sep 30 18:57:42 2009 +0200
@@ -223,11 +223,15 @@
             conditions = (conditions,)
         for expr in conditions:
             if isinstance(expr, str):
-                expr = unicode(expr)
+                kwargs = {'expr': unicode(expr)}
+            elif isinstance(expr, dict):
+                kwargs = expr
+            kwargs['x'] = self.eid
+            kwargs.setdefault('mainvars', u'X')
             self._cw.execute('INSERT RQLExpression X: X exprtype "ERQLExpression", '
                              'X expression %(expr)s, T condition X '
                              'WHERE T eid %(x)s',
-                             {'x': self.eid, 'expr': expr}, 'x')
+                             'T condition X WHERE T eid %(x)s', kwargs, 'x')
         # XXX clear caches?
 
 
@@ -415,16 +419,24 @@
             self.warning("can't find any workflow for %s", self.__regid__)
         return None
 
-    def possible_transitions(self):
+    def possible_transitions(self, type='normal'):
         """generates transition that MAY be fired for the given entity,
         expected to be in this state
         """
         if self.current_state is None or self.current_workflow is None:
             return
+<<<<<<< /home/syt/src/fcubicweb/cubicweb/entities/wfobjs.py
         rset = self._cw.execute(
             'Any T,N WHERE S allowed_transition T, S eid %(x)s, '
             'T name N, T transition_of WF, WF eid %(wfeid)s',
             {'x': self.current_state.eid,
+=======
+        rset = self.req.execute(
+            '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': type,
+>>>>>>> /tmp/wfobjs.py~other.TyHPqT
              'wfeid': self.current_workflow.eid}, 'x')
         for tr in rset.entities():
             if tr.may_be_fired(self.eid):
@@ -446,15 +458,21 @@
             kwargs['S'] = tseid
         return self._cw.create_entity('TrInfo', *args, **kwargs)
 
-    def fire_transition(self, trname, comment=None, commentformat=None):
+    def fire_transition(self, tr, comment=None, commentformat=None):
         """change the entity's state by firing transition of the given name in
         entity's workflow
         """
         assert self.current_workflow
+<<<<<<< /home/syt/src/fcubicweb/cubicweb/entities/wfobjs.py
         tr = self.current_workflow.transition_by_name(trname)
         if tr is None:
             raise WorkflowException('not a %s transition: %s' % (self.__regid__,
                                                                  trname))
+=======
+        if isinstance(tr, basestring):
+            tr = self.current_workflow.transition_by_name(tr)
+        assert tr is not None, 'not a %s transition: %s' % (self.id, tr)
+>>>>>>> /tmp/wfobjs.py~other.TyHPqT
         return self._add_trinfo(comment, commentformat, tr.eid)
 
     def change_state(self, statename, comment=None, commentformat=None, tr=None):