[req / session] drop is_internal_session (buggy) compat on base request by implementing necessary methods on internal manager
--- 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'))