[multi-sources-removal] Drop foreid argument of repo.get_option_value
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 21 Jun 2013 17:53:44 +0200
changeset 9458 e2dfdd313dfe
parent 9457 d5ed6efd6448
child 9459 d3016c08b4ae
[multi-sources-removal] Drop foreid argument of repo.get_option_value It doesn't need it anymore. Related to #2919300
dbapi.py
repoapi.py
server/repository.py
server/session.py
--- a/dbapi.py	Fri Jun 21 16:17:17 2013 +0200
+++ b/dbapi.py	Fri Jun 21 17:53:44 2013 +0200
@@ -288,7 +288,10 @@
         self.set_default_language(vreg)
 
     def get_option_value(self, option, foreid=None):
-        return self.cnx.get_option_value(option, foreid)
+        if foreid is not None:
+            warn('[3.19] foreid argument is deprecated', DeprecationWarning,
+                 stacklevel=2)
+        return self.cnx.get_option_value(option)
 
     def set_session(self, session):
         """method called by the session handler when the user is authenticated
@@ -659,11 +662,14 @@
 
     @check_not_closed
     def get_option_value(self, option, foreid=None):
-        """Return the value for `option` in the configuration. If `foreid` is
-        specified, the actual repository to which this entity belongs is
-        dereferenced and the option value retrieved from it.
+        """Return the value for `option` in the configuration.
+
+        `foreid` argument is deprecated and now useless (as of 3.19).
         """
-        return self._repo.get_option_value(option, foreid)
+        if foreid is not None:
+            warn('[3.19] foreid argument is deprecated', DeprecationWarning,
+                 stacklevel=2)
+        return self._repo.get_option_value(option)
 
     @check_not_closed
     def describe(self, eid, asdict=False):
--- a/repoapi.py	Fri Jun 21 16:17:17 2013 +0200
+++ b/repoapi.py	Fri Jun 21 17:53:44 2013 +0200
@@ -17,6 +17,7 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 """Official API to access the content of a repository
 """
+from warnings import warn
 
 from logilab.common.deprecation import deprecated
 
@@ -243,6 +244,9 @@
         specified, the actual repository to which this entity belongs is
         dereferenced and the option value retrieved from it.
         """
+        if foreid is not None:
+            warn('[3.19] foreid argument is deprecated', DeprecationWarning,
+                 stacklevel=2)
         return self._session.repo.get_option_value(option, foreid)
 
     describe = _srv_cnx_func('describe')
--- a/server/repository.py	Fri Jun 21 16:17:17 2013 +0200
+++ b/server/repository.py	Fri Jun 21 17:53:44 2013 +0200
@@ -543,31 +543,17 @@
         return cubes
 
     def get_option_value(self, option, foreid=None):
-        """Return the value for `option` in the configuration. If `foreid` is
-        specified, the actual repository to which this entity belongs is
-        derefenced and the option value retrieved from it.
+        """Return the value for `option` in the configuration.
 
         This is a public method, not requiring a session id.
+
+        `foreid` argument is deprecated and now useless (as of 3.19).
         """
+        if foreid is not None:
+            warn('[3.19] foreid argument is deprecated', DeprecationWarning,
+                 stacklevel=2)
         # XXX we may want to check we don't give sensible information
-        # XXX the only cube using 'foreid', apycot, stop used this, we probably
-        # want to drop this argument
-        if foreid is None:
-            return self.config[option]
-        _, sourceuri, extid, _ = self.type_and_source_from_eid(foreid)
-        if sourceuri == 'system':
-            return self.config[option]
-        cnxset = self._get_cnxset()
-        try:
-            cnx = cnxset.connection(sourceuri)
-            # needed to check connection is valid and usable by the current
-            # thread
-            newcnx = self.sources_by_uri[sourceuri].check_connection(cnx)
-            if newcnx is not None:
-                cnx = newcnx
-            return cnx.get_option_value(option, extid)
-        finally:
-            self._free_cnxset(cnxset)
+        return self.config[option]
 
     @cached
     def get_versions(self, checkversions=False):
--- a/server/session.py	Fri Jun 21 16:17:17 2013 +0200
+++ b/server/session.py	Fri Jun 21 17:53:44 2013 +0200
@@ -1438,7 +1438,10 @@
 
     @deprecated('[3.19] use a Connection object instead')
     def get_option_value(self, option, foreid=None):
-        return self.repo.get_option_value(option, foreid)
+        if foreid is not None:
+            warn('[3.19] foreid argument is deprecated', DeprecationWarning,
+                 stacklevel=2)
+        return self.repo.get_option_value(option)
 
     @deprecated('[3.19] use a Connection object instead')
     def transaction(self, free_cnxset=True):