Colin Doherty
coldoherty68 at yahoo.co.uk
Wed Feb 2 14:37:41 EST 2005
Hi, I've tried a few of the suggested fixes but none work if I reference the session variable in the auth() method: #setting it in the class definition class mpseg(Servlet): __msg = '' auth_realm = 'Private' use_session = True def auth(self): if self.session.is_new(): user,pw = self._get_user_pw() if user == 'user' and pw == 'password': self.__msg = 'Hi' return else: self._unauthorized() if not self.session.is_new(): self.__msg = 'Welcome back' def respond(self): self.writeln(self.__msg) return True #using call to base class from mod_python.servlet import Servlet class mpseg(Servlet): __msg = '' auth_realm = 'Private' def __init__(self): Servlet.__init__(self) def auth(self): #also tried adding Servlet.auth(self) if self.session.is_new(): user,pw = self._get_user_pw() if user == 'user' and pw == 'password': self.__msg = 'Hi' return else: self._unauthorized() if not self.session.is_new(): self.__msg = 'Welcome back' def prep(self): self.use_session = True Servlet.prep(self) def respond(self): self.writeln(self.__msg) return True If I remove the auth() method it works: from mod_python.servlet import Servlet class mpseg(Servlet): __msg = '' auth_realm = 'Private' use_session = True def respond(self): if self.session.is_new(): self.__msg = 'new' if not self.session.is_new(): self.__msg = 'old' self.writeln(self.__msg) return True So I'm either still missing something or there is no direct way of referencing the session variable in an auth call - this would make sense if auth is called before prep as it appears from the docs. BTW the servlet handler seems excellent as far I have got it working, would it make the basis for either a python J2EE equivalent ? TIA Cheers Colin ___________________________________________________________ ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
|