[repository] deprecate the extid2eid based multi-sources API
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 30 Jun 2015 10:06:00 +0200
changeset 10914 fed8bd56f223
parent 10913 5d7f17054ae6
child 10915 cf800aa43f48
[repository] deprecate the extid2eid based multi-sources API This API is cumbersome and lead to obfuscated code because of the callback mecanism implied when some entity has to be created. Since we dropped the "true" multi-source, this mecanism is not needed anymore and one should prefer to use the dataimport API inside its parser instead. Notice the cwxml parser will trigger the deprecation warning, it should not be used anymore in favor of ad-hoc parsers.
server/repository.py
server/sources/datafeed.py
--- a/server/repository.py	Mon Nov 23 14:37:37 2015 +0100
+++ b/server/repository.py	Tue Jun 30 10:06:00 2015 +0200
@@ -775,6 +775,7 @@
             args[key] = int(args[key])
         return tuple(cachekey)
 
+    @deprecated('[3.22] use the new store API')
     def extid2eid(self, source, extid, etype, cnx, insert=True,
                   sourceparams=None):
         """Return eid from a local id. If the eid is a negative integer, that
--- a/server/sources/datafeed.py	Mon Nov 23 14:37:37 2015 +0100
+++ b/server/sources/datafeed.py	Tue Jun 30 10:06:00 2015 +0200
@@ -31,6 +31,8 @@
 
 from lxml import etree
 
+from logilab.common.deprecation import deprecated
+
 from cubicweb import RegistryNotFound, ObjectNotFound, ValidationError, UnknownEid
 from cubicweb.server.repository import preprocess_inlined_relations
 from cubicweb.server.sources import AbstractSource
@@ -247,6 +249,7 @@
                 error = True
         return error
 
+    @deprecated('[3.21] use the new store API')
     def before_entity_insertion(self, cnx, lid, etype, eid, sourceparams):
         """called by the repository when an eid has been attributed for an
         entity stored here but the entity has not been inserted in the system
@@ -262,6 +265,7 @@
         sourceparams['parser'].before_entity_copy(entity, sourceparams)
         return entity
 
+    @deprecated('[3.21] use the new store API')
     def after_entity_insertion(self, cnx, lid, entity, sourceparams):
         """called by the repository after an entity stored here has been
         inserted in the system table.
@@ -373,6 +377,7 @@
         msg = schemacfg._cw._("this parser doesn't use a mapping")
         raise ValidationError(schemacfg.eid, {None: msg})
 
+    @deprecated('[3.21] use the new store API')
     def extid2entity(self, uri, etype, **sourceparams):
         """Return an entity for the given uri. May return None if it should be
         skipped.
@@ -422,9 +427,11 @@
         """main callback: process the url"""
         raise NotImplementedError
 
+    @deprecated('[3.21] use the new store API')
     def before_entity_copy(self, entity, sourceparams):
         raise NotImplementedError
 
+    @deprecated('[3.21] use the new store API')
     def after_entity_copy(self, entity, sourceparams):
         self.stats['created'].add(entity.eid)
 
@@ -475,6 +482,7 @@
 
 class DataFeedXMLParser(DataFeedParser):
 
+    @deprecated()
     def process(self, url, raise_on_error=False):
         """IDataFeedParser main entry point"""
         try: