[mod_python] error with session handling in mod_python.servlet

Vinj Vinj vinjvinj at yahoo.com
Thu Sep 2 12:36:37 EDT 2004


That's strange. I reinstalled the mod_python and the
write functions disappeared from mod_python function.

I then got new errors which claim that the cookie does
not have the path attribute. I had to replace:

                docroot = self._req.document_root()
                # the path where *Handler directive
was specified
                dirpath = self._req.hlist.directory
                c.path = dirpath[len(docroot):]

                # 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 = '/'


with:

            try:
                docroot = self._req.document_root()
                # the path where *Handler directive
was specified
                dirpath = self._req.hlist.directory
                c.path = dirpath[len(docroot):]

                # 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 = '/'
            except:
                c.path = '/'

Will this mess anything else? I am using alias in the
mod_python configuration. 

thanks.

----------------------------------------------------
I'm get the following errow ehn I use :

use_session in the servlet.

I'm get the same error in the tutorial as well. Any
clues on what might be going wrong?

Thanks.


Mod_python error: "PythonHandler mod_python.servlet"

Traceback (most recent call last):

  File
"C:\Python23\Lib\site-packages\mod_python\apache.py",
line 299, in HandlerDispatch
    result = object(req)

  File
"C:\Python23\lib\site-packages\mod_python\servlet.py",
line 1453, in handler
    servlet.prep()

  File
"C:\Python23\lib\site-packages\mod_python\servlet.py",
line 593, in prep
    timeout=self.session_timeout)

  File
"C:\Python23\lib\site-packages\mod_python\Session.py",
line 388, in Session
    timeout=timeout, lock=lock)

  File
"C:\Python23\lib\site-packages\mod_python\Session.py",
line 360, in __init__
    timeout=timeout, lock=lock)

  File
"C:\Python23\lib\site-packages\mod_python\Session.py",
line 132, in __init__
    Cookie.add_cookie(self._req, self.make_cookie())

  File
"C:\Python23\lib\site-packages\mod_python\Session.py",
line 165, in make_cookie
    self.write(c)

AttributeError: 'MemorySession' object has no
attribute 'write'
_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://mailman.modpython.org/mailman/listinfo/mod_python


More information about the Mod_python mailing list