cubicweb/hooks/syncsources.py
branch3.25
changeset 12142 db2fc87348ab
parent 11775 39cf9e55ada8
child 12150 6260c88e0ff5
--- a/cubicweb/hooks/syncsources.py	Tue Feb 21 11:04:19 2017 +0100
+++ b/cubicweb/hooks/syncsources.py	Tue Apr 04 16:28:50 2017 +0200
@@ -35,11 +35,6 @@
 
 # repo sources synchronization #################################################
 
-class SourceAddedOp(hook.Operation):
-    entity = None # make pylint happy
-    def postcommit_event(self):
-        self.cnx.repo.add_source(self.entity)
-
 class SourceAddedHook(SourceHook):
     __regid__ = 'cw.sources.added'
     __select__ = SourceHook.__select__ & is_instance('CWSource')
@@ -56,14 +51,8 @@
         if self.entity.name != 'system':
             sourcecls.check_conf_dict(self.entity.eid, self.entity.host_config,
                                       fail_if_unknown=not self._cw.vreg.config.repairing)
-            SourceAddedOp(self._cw, entity=self.entity)
 
 
-class SourceRemovedOp(hook.Operation):
-    uri = None # make pylint happy
-    def postcommit_event(self):
-        self.cnx.repo.remove_source(self.uri)
-
 class SourceRemovedHook(SourceHook):
     __regid__ = 'cw.sources.removed'
     __select__ = SourceHook.__select__ & is_instance('CWSource')
@@ -72,34 +61,6 @@
         if self.entity.name == 'system':
             msg = _("You cannot remove the system source")
             raise validation_error(self.entity, {None: msg})
-        SourceRemovedOp(self._cw, uri=self.entity.name)
-
-
-class SourceConfigUpdatedOp(hook.DataOperationMixIn, hook.Operation):
-
-    def precommit_event(self):
-        self.__processed = []
-        for source in self.get_data():
-            if not self.cnx.deleted_in_transaction(source.eid):
-                conf = source.repo_source.check_config(source)
-                self.__processed.append( (source, conf) )
-
-    def postcommit_event(self):
-        for source, conf in self.__processed:
-            source.repo_source.update_config(source, conf)
-
-
-class SourceRenamedOp(hook.LateOperation):
-    oldname = newname = None # make pylint happy
-
-    def postcommit_event(self):
-        repo = self.cnx.repo
-        # XXX race condition
-        source = repo.sources_by_uri.pop(self.oldname)
-        source.uri = self.newname
-        source.public_config['uri'] = self.newname
-        repo.sources_by_uri[self.newname] = source
-        clear_cache(repo, 'source_defs')
 
 
 class SourceUpdatedHook(SourceHook):
@@ -112,26 +73,8 @@
             if oldname == 'system':
                 msg = _("You cannot rename the system source")
                 raise validation_error(self.entity, {('name', 'subject'): msg})
-            SourceRenamedOp(self._cw, oldname=oldname, newname=newname)
         if 'config' in self.entity.cw_edited or 'url' in self.entity.cw_edited:
             if self.entity.name == 'system' and self.entity.config:
                 msg = _("Configuration of the system source goes to "
                         "the 'sources' file, not in the database")
                 raise validation_error(self.entity, {('config', 'subject'): msg})
-            SourceConfigUpdatedOp.get_instance(self._cw).add_data(self.entity)
-
-
-class SourceHostConfigUpdatedHook(SourceHook):
-    __regid__ = 'cw.sources.hostconfigupdate'
-    __select__ = SourceHook.__select__ & is_instance('CWSourceHostConfig')
-    events = ('after_add_entity', 'after_update_entity', 'before_delete_entity',)
-    def __call__(self):
-        if self.entity.match(gethostname()):
-            if self.event == 'after_update_entity' and \
-                   not 'config' in self.entity.cw_edited:
-                return
-            try:
-                SourceConfigUpdatedOp.get_instance(self._cw).add_data(self.entity.cwsource)
-            except IndexError:
-                # XXX no source linked to the host config yet
-                pass