[dbapi] allow talking to a pre-3.19 remote repository
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 01 Jul 2014 17:25:25 +0200
changeset 9830 465d8151b92d
parent 9829 e0e71b45bf8d
child 9831 db4aeba5d336
[dbapi] allow talking to a pre-3.19 remote repository Closes #4071285
dbapi.py
--- a/dbapi.py	Tue Jun 17 11:56:38 2014 +0200
+++ b/dbapi.py	Tue Jul 01 17:25:25 2014 +0200
@@ -679,7 +679,16 @@
     @check_not_closed
     def entity_metas(self, eid):
         """return a tuple (type, sourceuri, extid) for the entity with id <eid>"""
-        return self._repo.entity_metas(self.sessionid, eid, **self._txid())
+        try:
+            return self._repo.entity_metas(self.sessionid, eid, **self._txid())
+        except AttributeError:
+            # talking to pre 3.19 repository
+            metas = self._repo.describe(self.sessionid, eid, **self._txid())
+            if len(metas) == 3: # even older backward compat
+                metas = list(metas)
+                metas.append(metas[1])
+            return dict(zip(('type', 'source', 'extid', 'asource'), metas))
+
 
     @deprecated('[3.19] use .entity_metas(eid) instead')
     @check_not_closed