[cwuser] make CWUser callable, returning self for dbapi compatibility
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 21 Jun 2013 12:08:06 +0200
changeset 9059 795ea498225f
parent 9058 2f45e99ad753
child 9060 8c0016d7a091
[cwuser] make CWUser callable, returning self for dbapi compatibility In the dbapi, Connection and Session have a ``user`` method to generated a user for a request In the repo api, Connection and Session have a user attribute inherited from SessionRequestBase prototype. This ugly hack allows to not break user of the user method. To ease transition from dbapi to repoapi we need the ClientConnection to be as compatible as possible with the dbapi. Adding this method goes in this direction. It'll get deprecated in the deprecation wave that will conclude the repoapi refactoring. related to #2503918
entities/authobjs.py
--- a/entities/authobjs.py	Fri Jun 21 15:26:03 2013 +0200
+++ b/entities/authobjs.py	Fri Jun 21 12:08:06 2013 +0200
@@ -166,6 +166,17 @@
 
     dc_long_title = name
 
+    def __call__(self, *args, **kwargs):
+        """ugly hack for compatibility betweeb dbapi and repo api
+
+        In the dbapi, Connection and Session have a ``user`` method to
+        generated a user for a request In the repo api, Connection and Session
+        have a user attribute inherited from SessionRequestBase prototype. This
+        ugly hack allows to not break user of the user method.
+
+        XXX Deprecate me ASAP"""
+        return self
+
 from logilab.common.deprecation import class_renamed
 EUser = class_renamed('EUser', CWUser)
 EGroup = class_renamed('EGroup', CWGroup)