equal
deleted
inserted
replaced
28 class SourceHook(hook.Hook): |
28 class SourceHook(hook.Hook): |
29 __abstract__ = True |
29 __abstract__ = True |
30 category = 'cw.sources' |
30 category = 'cw.sources' |
31 |
31 |
32 |
32 |
|
33 # repo sources synchronization ################################################# |
|
34 |
33 class SourceAddedOp(hook.Operation): |
35 class SourceAddedOp(hook.Operation): |
34 def postcommit_event(self): |
36 def postcommit_event(self): |
35 self.session.repo.add_source(self.entity) |
37 self.session.repo.add_source(self.entity) |
36 |
38 |
37 class SourceAddedHook(SourceHook): |
39 class SourceAddedHook(SourceHook): |
49 fail_if_unknown=not self._cw.vreg.config.repairing) |
51 fail_if_unknown=not self._cw.vreg.config.repairing) |
50 SourceAddedOp(self._cw, entity=self.entity) |
52 SourceAddedOp(self._cw, entity=self.entity) |
51 |
53 |
52 |
54 |
53 class SourceRemovedOp(hook.Operation): |
55 class SourceRemovedOp(hook.Operation): |
54 def precommit_event(self): |
56 def postcommit_event(self): |
55 self.session.repo.remove_source(self.uri) |
57 self.session.repo.remove_source(self.uri) |
56 |
58 |
57 class SourceRemovedHook(SourceHook): |
59 class SourceRemovedHook(SourceHook): |
58 __regid__ = 'cw.sources.removed' |
60 __regid__ = 'cw.sources.removed' |
59 __select__ = SourceHook.__select__ & is_instance('CWSource') |
61 __select__ = SourceHook.__select__ & is_instance('CWSource') |
67 class SourceUpdatedOp(hook.DataOperationMixIn, hook.Operation): |
69 class SourceUpdatedOp(hook.DataOperationMixIn, hook.Operation): |
68 |
70 |
69 def precommit_event(self): |
71 def precommit_event(self): |
70 self.__processed = [] |
72 self.__processed = [] |
71 for source in self.get_data(): |
73 for source in self.get_data(): |
72 conf = source.repo_source.check_config(source) |
74 if not self.session.deleted_in_transaction(source.eid): |
73 self.__processed.append( (source, conf) ) |
75 conf = source.repo_source.check_config(source) |
|
76 self.__processed.append( (source, conf) ) |
74 |
77 |
75 def postcommit_event(self): |
78 def postcommit_event(self): |
76 for source, conf in self.__processed: |
79 for source, conf in self.__processed: |
77 source.repo_source.update_config(source, conf) |
80 source.repo_source.update_config(source, conf) |
78 |
81 |
98 except IndexError: |
101 except IndexError: |
99 # XXX no source linked to the host config yet |
102 # XXX no source linked to the host config yet |
100 pass |
103 pass |
101 |
104 |
102 |
105 |
103 # source mapping synchronization. Expect cw_for_source/cw_schema are immutable |
106 # source mapping synchronization ############################################### |
104 # relations (i.e. can't change from a source or schema to another). |
107 # |
|
108 # Expect cw_for_source/cw_schema are immutable relations (i.e. can't change from |
|
109 # a source or schema to another). |
105 |
110 |
106 class SourceMappingDeleteHook(SourceHook): |
111 class SourceMappingDeleteHook(SourceHook): |
107 """check cw_for_source and cw_schema are immutable relations |
112 """check cw_for_source and cw_schema are immutable relations |
108 |
113 |
109 XXX empty delete perms would be enough? |
114 XXX empty delete perms would be enough? |