[mod_python] servlet sessions

Colin Doherty coldoherty68 at yahoo.co.uk
Wed Feb 2 03:47:18 EST 2005


Hi,

I'm having difficulty getting sessions working in
modpython.servlet, the tutorial example works so it
would appear to be an error in my code rather than
apache/mod_python set up:

from mod_python.servlet import Servlet

class mpseg(Servlet):
    __msg = ''
    auth_realm = 'Private'
    
    def __init__(self):
        Servlet.__init__(self)

    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 prep(self):
        use_session = True

    def respond(self):
        self.writeln(self.__msg)
        return True

>From what I gather setting use_session = True should
create a session instance variable for this user, but
I'm receiving this error:

AttributeError: 'NoneType' object has no attribute
'is_new' - which appears to indicate that an instance
of session isn't being created ?

Any help appreciated.

TIA
Colin



	
	
		
___________________________________________________________ 
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com


More information about the Mod_python mailing list