33 add_entity_type('WorkflowTransition') |
33 add_entity_type('WorkflowTransition') |
34 add_entity_type('SubWorkflowExitPoint') |
34 add_entity_type('SubWorkflowExitPoint') |
35 # drop explicit 'State allowed_transition Transition' since it should be |
35 # drop explicit 'State allowed_transition Transition' since it should be |
36 # infered due to yams inheritance. However we've to disable the schema |
36 # infered due to yams inheritance. However we've to disable the schema |
37 # sync hook first to avoid to destroy existing data... |
37 # sync hook first to avoid to destroy existing data... |
38 from cubicweb.server.schemahooks import after_del_relation_type |
|
39 repo.hm.unregister_hook(after_del_relation_type, |
|
40 'after_delete_relation', 'relation_type') |
|
41 try: |
38 try: |
42 drop_relation_definition('State', 'allowed_transition', 'Transition') |
39 from cubicweb.hooks import syncschema |
43 finally: |
40 repo.vreg.unregister(syncschema.AfterDelRelationTypeHook) |
44 repo.hm.register_hook(after_del_relation_type, |
41 try: |
45 'after_delete_relation', 'relation_type') |
42 drop_relation_definition('State', 'allowed_transition', 'Transition') |
|
43 finally: |
|
44 repo.vreg.register(syncschema.AfterDelRelationTypeHook) |
|
45 except ImportError: # syncschema is in CW >= 3.6 only |
|
46 from cubicweb.server.schemahooks import after_del_relation_type |
|
47 repo.hm.unregister_hook(after_del_relation_type, |
|
48 'after_delete_relation', 'relation_type') |
|
49 try: |
|
50 drop_relation_definition('State', 'allowed_transition', 'Transition') |
|
51 finally: |
|
52 repo.hm.register_hook(after_del_relation_type, |
|
53 'after_delete_relation', 'relation_type') |
46 schema.rebuild_infered_relations() # need to be explicitly called once everything is in place |
54 schema.rebuild_infered_relations() # need to be explicitly called once everything is in place |
47 |
55 |
48 for et in rql('DISTINCT Any ET,ETN WHERE S state_of ET, ET name ETN', |
56 for et in rql('DISTINCT Any ET,ETN WHERE S state_of ET, ET name ETN', |
49 ask_confirm=False).entities(): |
57 ask_confirm=False).entities(): |
50 wf = add_workflow(u'default %s workflow' % et.name, et.name, |
58 wf = add_workflow(u'default %s workflow' % et.name, et.name, |