[req / session] drop is_internal_session (buggy) compat on base request by implementing necessary methods on internal manager
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 11 Oct 2012 18:42:13 +0200
changeset 8579 c4673bc11053
parent 8578 f6ea4ea63d57
child 8580 d753d6a6798f
[req / session] drop is_internal_session (buggy) compat on base request by implementing necessary methods on internal manager
req.py
server/session.py
--- a/req.py	Thu Sep 20 16:33:51 2012 +0200
+++ b/req.py	Thu Oct 11 18:42:13 2012 +0200
@@ -318,21 +318,12 @@
     def user_data(self):
         """returns a dictionary with this user's information"""
         userinfo = {}
-        if self.is_internal_session:
-            userinfo['login'] = "cubicweb"
-            userinfo['name'] = "cubicweb"
-            userinfo['email'] = ""
-            return userinfo
         user = self.user
         userinfo['login'] = user.login
         userinfo['name'] = user.name()
         userinfo['email'] = user.cw_adapt_to('IEmailable').get_email()
         return userinfo
 
-    def is_internal_session(self):
-        """overrided on the server-side"""
-        return False
-
     # formating methods #######################################################
 
     def view(self, __vid, rset=None, __fallback_oid=None, __registry='views',
--- a/server/session.py	Thu Sep 20 16:33:51 2012 +0200
+++ b/server/session.py	Thu Oct 11 18:42:13 2012 +0200
@@ -1217,6 +1217,21 @@
         # mock CWUser.prefered_language, mainly for testing purpose
         return self.property_value('ui.language')
 
+    # CWUser compat for notification ###########################################
+
+    def name(self):
+        return 'cubicweb'
+
+    class _IEmailable:
+        @staticmethod
+        def get_email():
+            return ''
+
+    def cw_adapt_to(self, iface):
+        if iface == 'IEmailable':
+            return self._IEmailable
+        return None
+
 from logging import getLogger
 from cubicweb import set_log_methods
 set_log_methods(Session, getLogger('cubicweb.session'))