equal
deleted
inserted
replaced
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """hooks for repository sources synchronization""" |
18 """hooks for repository sources synchronization""" |
|
19 |
|
20 from socket import gethostname |
19 |
21 |
20 from yams.schema import role_name |
22 from yams.schema import role_name |
21 |
23 |
22 from cubicweb import ValidationError |
24 from cubicweb import ValidationError |
23 from cubicweb.selectors import is_instance |
25 from cubicweb.selectors import is_instance |
85 class SourceHostConfigUpdatedHook(SourceHook): |
87 class SourceHostConfigUpdatedHook(SourceHook): |
86 __regid__ = 'cw.sources.hostconfigupdate' |
88 __regid__ = 'cw.sources.hostconfigupdate' |
87 __select__ = SourceHook.__select__ & is_instance('CWSourceHostConfig') |
89 __select__ = SourceHook.__select__ & is_instance('CWSourceHostConfig') |
88 events = ('after_add_entity', 'after_update_entity', 'before_delete_entity',) |
90 events = ('after_add_entity', 'after_update_entity', 'before_delete_entity',) |
89 def __call__(self): |
91 def __call__(self): |
90 try: |
92 if self.entity.match_host(gethostname()): |
91 SourceUpdatedOp.get_instance(self._cw).add_data(self.entity.cwsource) |
93 if self.event == 'after_update_entity' and \ |
92 except IndexError: |
94 not 'config' in self.entity.cw_edited: |
93 # XXX no source linked to the host config yet |
95 return |
94 pass |
96 try: |
|
97 SourceUpdatedOp.get_instance(self._cw).add_data(self.entity.cwsource) |
|
98 except IndexError: |
|
99 # XXX no source linked to the host config yet |
|
100 pass |
95 |
101 |
96 |
102 |
97 # source mapping synchronization. Expect cw_for_source/cw_schema are immutable |
103 # source mapping synchronization. Expect cw_for_source/cw_schema are immutable |
98 # relations (i.e. can't change from a source or schema to another). |
104 # relations (i.e. can't change from a source or schema to another). |
99 |
105 |