[multi-sources] in ms config, don't try to delete previous state in some condition 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 27 Aug 2009 16:59:19 +0200
branch3.5
changeset 3039 7d5a4d27d052
parent 3038 1261c3df0e5a
child 3040 e4dc22040f5f
[multi-sources] in ms config, don't try to delete previous state in some condition
server/hooks.py
--- a/server/hooks.py	Thu Aug 27 16:58:20 2009 +0200
+++ b/server/hooks.py	Thu Aug 27 16:59:19 2009 +0200
@@ -425,7 +425,12 @@
     nocheck.add((x, 'in_state', oldstate))
     nocheck.add((x, 'in_state', newstate))
     # delete previous state first in case we're using a super session
-    session.delete_relation(x, 'in_state', oldstate)
+    fromsource = session.describe(x)[1]
+    # don't try to remove previous state if in_state isn't stored in the system
+    # source
+    if fromsource == 'system' or \
+       not session.repo.sources_by_uri[fromsource].support_relation('in_state'):
+        session.delete_relation(x, 'in_state', oldstate)
     session.add_relation(x, 'in_state', newstate)
 
 
@@ -514,7 +519,7 @@
     _change_state(session, entity['wf_info_for'],
                   entity['from_state'], entity['to_state'])
     forentity = session.entity_from_eid(entity['wf_info_for'])
-    assert forentity.current_state.eid == entity['to_state']
+    assert forentity.current_state.eid == entity['to_state'], forentity.current_state.name
     if forentity.main_workflow.eid != forentity.current_workflow.eid:
         # we're in a subworkflow, check if we've reached an exit point
         wftr = forentity.subworkflow_input_transition()