cubicweb/hooks/metadata.py
changeset 11774 51c160677afe
parent 11773 054a947b5415
--- a/cubicweb/hooks/metadata.py	Fri Sep 30 17:38:12 2016 +0200
+++ b/cubicweb/hooks/metadata.py	Wed Oct 05 15:30:10 2016 +0200
@@ -147,55 +147,3 @@
         elif ftcontainer == 'object':
             cnx.repo.system_source.index_entity(
                 cnx, cnx.entity_from_eid(self.eidto))
-
-
-
-# entity source handling #######################################################
-
-class ChangeEntitySourceUpdateCaches(hook.Operation):
-    oldsource = entity = None # make pylint happy
-
-    def postcommit_event(self):
-        self.oldsource.reset_caches()
-        repo = self.cnx.repo
-        entity = self.entity
-        repo._type_extid_cache[entity.eid] = (entity.cw_etype, None)
-
-
-class ChangeEntitySourceDeleteHook(MetaDataHook):
-    """support for moving an entity from an external source by watching 'Any
-    cw_source CWSource' relation
-    """
-
-    __regid__ = 'cw.metadata.source-change'
-    __select__ = MetaDataHook.__select__ & hook.match_rtype('cw_source')
-    events = ('before_delete_relation',)
-
-    def __call__(self):
-        if (self._cw.deleted_in_transaction(self.eidfrom)
-            or self._cw.deleted_in_transaction(self.eidto)):
-            return
-        schange = self._cw.transaction_data.setdefault('cw_source_change', {})
-        schange[self.eidfrom] = self.eidto
-
-
-class ChangeEntitySourceAddHook(MetaDataHook):
-    __regid__ = 'cw.metadata.source-change'
-    __select__ = MetaDataHook.__select__ & hook.match_rtype('cw_source')
-    events = ('before_add_relation',)
-
-    def __call__(self):
-        schange = self._cw.transaction_data.get('cw_source_change')
-        if schange is not None and self.eidfrom in schange:
-            newsource = self._cw.entity_from_eid(self.eidto)
-            if newsource.name != 'system':
-                raise Exception('changing source to something else than the '
-                                'system source is unsupported')
-            syssource = newsource.repo_source
-            oldsource = self._cw.entity_from_eid(schange[self.eidfrom])
-            entity = self._cw.entity_from_eid(self.eidfrom)
-            attrs = {'type': entity.cw_etype, 'eid': entity.eid, 'extid': None}
-            self._cw.system_sql(syssource.sqlgen.update('entities', attrs, ['eid']), attrs)
-            # register an operation to update repository/sources caches
-            ChangeEntitySourceUpdateCaches(self._cw, entity=entity,
-                                           oldsource=oldsource.repo_source)