Commit 975e7835 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

3.5 api

parent 362a3f275a27
......@@ -17,7 +17,7 @@ from logilab.mtconverter import TransformError
from cubicweb import UnknownEid
from cubicweb.server.pool import PreCommitOperation
from cubicweb.server.hooksmanager import Hook
from cubicweb.sobjects.notification import parse_message_id
from cubicweb.common.mail import parse_message_id
def fix_ownership(session, eid, email):
......@@ -90,10 +90,10 @@ class ExtractEmailChangeState(PreCommitOperation):
if not hasattr(entity, 'in_state'):
self.error('bad change state instruction for eid %s', eid)
continue
transition = entity.can_pass_transition(trname)
if transition:
tr = entity.current_workflow and entity.current_workflow.transition_by_name(trname)
if tr and tr.may_be_fired(entity.eid):
try:
self.change_state(entity, transition)
self.change_state(entity, tr)
except:
self.exception('while changing state off %s from email %s',
entity, self.email)
......@@ -102,8 +102,7 @@ class ExtractEmailChangeState(PreCommitOperation):
trname, entity)
def change_state(self, entity, transition):
entity.change_state(transition.destination_state[0].eid)
trinfo = entity.latest_trinfo()
trinfo = entity.fire_transition(transition)
self.session.execute('SET X generated_by S WHERE X eid %(x)s, S eid %(s)s',
{'x': trinfo.eid, 's': self.email.eid}, 'x')
fix_ownership(self.session, trinfo.eid, self.email)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment