[mod_python] Session problem

Matthias Julius lists at julius-net.net
Wed Nov 2 15:53:12 EST 2005


Ken Bradshaw <bradshak at us.ibm.com> writes:

>       My email is a little slow so my apologies if this has already been
> resolved.  It appears the most minimal handler you can have in your
> environment is more like this:
>
> from mod_python import apache, Session
>
> def index(req):
>         req.content_type = 'text/html'
>         s = Session.Session(req)
>         req.write(' ')
>         return apache.OK

My actual script is longer than what I wrote.  But, everything else
seems to be not relevant.

>From Session.py out of make_cookie()
,----
| docroot = self._req.document_root()
| # the path where *Handler directive was specified
| dirpath = self._req.hlist.directory
This returns None.  And req.hlist.directory is not mentioned in the
documentation for the Request Object.

| c.path = dirpath[len(docroot):]
And this fails because None is not subscriptable.

| 
| # XXX Not sure why, but on Win32 hlist.directory
| # may contain a trailing \ - need to investigate,
| # this value is given to us directly by httpd
| if os.name == 'nt' and c.path[-1] == '\\':
|     c.path = c.path[:-1]
| 
| # Sometimes there is no path, e.g. when Location
| # is used. When Alias or UserDir are used, then
| # the path wouldn't match the URI. In those cases
| # just default to '/'
| if not c.path or not self._req.uri.startswith(c.path):
|     c.path = '/'
`----

Is this a bug in Session.py?

Matthias



More information about the Mod_python mailing list