hooks/workflow.py
changeset 3072 6fb42c53f6df
parent 3024 bfaf056f1029
child 3376 f5c69485381f
equal deleted inserted replaced
3035:2e4a381ea5b7 3072:6fb42c53f6df
    18 
    18 
    19 def _change_state(session, x, oldstate, newstate):
    19 def _change_state(session, x, oldstate, newstate):
    20     nocheck = session.transaction_data.setdefault('skip-security', set())
    20     nocheck = session.transaction_data.setdefault('skip-security', set())
    21     nocheck.add((x, 'in_state', oldstate))
    21     nocheck.add((x, 'in_state', oldstate))
    22     nocheck.add((x, 'in_state', newstate))
    22     nocheck.add((x, 'in_state', newstate))
    23     # delete previous state first in case we're using a super session
    23     # delete previous state first in case we're using a super session,
    24     session.delete_relation(x, 'in_state', oldstate)
    24     # unless in_state isn't stored in the system source
       
    25     fromsource = session.describe(x)[1]
       
    26     if fromsource == 'system' or \
       
    27            not session.repo.sources_by_uri[fromsource].support_relation('in_state'):
       
    28         session.delete_relation(x, 'in_state', oldstate)
    25     session.add_relation(x, 'in_state', newstate)
    29     session.add_relation(x, 'in_state', newstate)
    26 
    30 
    27 
    31 
    28 # operations ###################################################################
    32 # operations ###################################################################
    29 
    33