Jim Gallacher
jpg at jgassociates.ca
Fri Sep 29 12:07:43 EDT 2006
Paul J. Pathiakis wrote: > Hi, > > would someone please respond to this? I've posted twice to this list and no one responds. This is the first time I've seen this question appear on the list. I checked the archives and it's not there either. > I'm sorry if this is such a low level question but I'd really like to get it working. That's not the problem. We just can't respond to things we don't see. :) > > I have index.py. It seems to be found by the browser and an attempt is made by python to render it and display it. However, I get the following: > > Mod_python error: "PythonHandler mod_python.publisher" > > Traceback (most recent call last): > > File "/usr/local/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch > result = object(req) > > File "/usr/local/lib/python2.4/site-packages/mod_python/publisher.py", line 213, in handler > published = publish_object(req, object) > > File "/usr/local/lib/python2.4/site-packages/mod_python/publisher.py", line 412, in publish_object > return publish_object(req,util.apply_fs_data(object, req.form, req=req)) > > File "/usr/local/lib/python2.4/site-packages/mod_python/util.py", line 439, in apply_fs_data > return object(**args) > > File "/usr/local/www/data/nav/index.py", line 44, in index > if req.session.has_key('user'): > > AttributeError: 'mp_request' object has no attribute 'session' > > > Now, I can see on line 44 in index.py there is the exact line right under the last part of the error. Why is the AttributeError being generated? Why is mp_request (mod_python reqest object) missing the attribute session? What is missing from httpd.conf file or other files that is not allowing this to continue? Without seeing nav/index.py I can only guess, but I assume req.session is not there for the same reason req.foobar is missing... Typical session usage looks like this: from mod_python util import Session def index(req): sess = Session.Session(req) if sess.is_new(): sess['user'] = 'blah' # stick the session instance into the request object # so it can be referenced in other function calls req.session = session _do_stuff(req) sess.save() def _do_stuff(req): req.write(req.session['user']) Jim
|