# HG changeset patch # User Sylvain Thénault # Date 1349973733 -7200 # Node ID c4673bc11053b5442e6dfcb526a8e62f2b924d8e # Parent f6ea4ea63d57d8d10355c8ea01b1d787d69089fc [req / session] drop is_internal_session (buggy) compat on base request by implementing necessary methods on internal manager diff -r f6ea4ea63d57 -r c4673bc11053 req.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', diff -r f6ea4ea63d57 -r c4673bc11053 server/session.py --- 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'))