[validatecontroller] allow additional args to be passed to the js callback
"""web session component: by dfault the session is actually the db connectionobject :/:organization: Logilab:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses"""__docformat__="restructuredtext en"fromcubicweb.webimportInvalidSessionfromcubicweb.web.applicationimportAbstractSessionManagerclassInMemoryRepositorySessionManager(AbstractSessionManager):"""manage session data associated to a session identifier"""def__init__(self):AbstractSessionManager.__init__(self)# XXX require a RepositoryAuthenticationManager which violates# authenticate interface by returning a session instead of a user#assert isinstance(self.authmanager, RepositoryAuthenticationManager)self._sessions={}defdump_data(self):returnself._sessionsdefrestore_data(self,data):self._sessions=datadefcurrent_sessions(self):returnself._sessions.values()defget_session(self,req,sessionid):"""return existing session for the given session identifier"""ifnotsessionidinself._sessions:raiseInvalidSession()session=self._sessions[sessionid]ifself.has_expired(session):self.close_session(session)raiseInvalidSession()# give an opportunity to auth manager to hijack the session# (necessary with the RepositoryAuthenticationManager in case# the connection to the repository has expired)try:session=self.authmanager.validate_session(req,session)# necessary in case session has been hijackedself._sessions[session.sessionid]=sessionexceptInvalidSession:# invalid sessiondelself._sessions[sessionid]raisereturnsessiondefopen_session(self,req):"""open and return a new session for the given request :raise ExplicitLogin: if authentication is required """session=self.authmanager.authenticate(req)self._sessions[session.sessionid]=sessionreturnsessiondefclose_session(self,session):"""close session on logout or on invalid session detected (expired out, corrupted...) """self.info('closing http session %s'%session)delself._sessions[session.sessionid]try:session.close()except:# already closed, may occurs if the repository session expired but# not the web sessionpass