[mod_python] Configuring Session.Session

Graham Dumpleton grahamd at dscpl.com.au
Tue Jun 28 18:24:43 EDT 2005


Now that I have been up for a few minutes and had a shower and my head 
is
clear, I can answer this properly.

It should not be necessary to use ApplicationPath provided that 
PythonHandler
is set at the root of each applications directory structure. To my 
mind, this
is the preferable thing to do than setting PythonHandler at some level 
above
and hosting multiple applications under the same place. The reason is 
that
the handler directory accessible by req.hlist.directory gives useful 
context
information about where the root of the application is. This can be 
used in
ways such as retrieving config or template files from near the root of 
the
application directory structure.

That said, the use of a distinct PythonHandler directive will not work 
to keep
the session contexts separate in the case where the the application 
directories
are not stored under the HTTP server document root. For example, if 
they are
stored in a user directory accessed using "/~user", or if the directory 
is mapped
into the URL namespace from elsewhere using Alias directive or other 
means. In
this case the ApplicationPath notionally is set to "/" so they will 
share the
same context regardless.

Note there is also currently a bug where if PythonHandler is defined in 
a Location
directive instead of a Directory directive you'll get a Python error. 
For now
one has to set ApplicationPath explicitly to avoid the bug, but in next 
version
it to will default to "/" in that case and so may still need to be 
overriden
explicitly in future to keep it separate.

Anyway, I would suggest simply setting PythonHandler at the root of 
each application
and only use ApplicationPath if one of the other situations is the case.

Graham

On 29/06/2005, at 7:56 AM, Nicolas Lehuen wrote:

> Duh, hence the code about ApplicationPath in 
> Session.Session.make_cookie. This should work, of course. Thanks, 
> Graham !
>
>  OK so Wayne, you may get what you want right now by setting the 
> ApplicationPath option :
>
> PythonOption ApplicationPath /path/to/my/app/as/an/url
>
>  For example if app1 is accessible through http://localhost/app1 and 
> app2 accessible through http://localhost/app2, then you would define 
> PythonOption ApplicationPath /app1 in a Directory section or in a 
> .htaccess file for your first app, and PythonOption ApplicationPath 
> /app2 for your second app.
>
> Tell us if this works for you.
>
>  Regards,
>  Nicolas
>
> 2005/6/28, Graham Dumpleton <grahamd at dscpl.com.au>:
>  At a quick glance I can't see how this may or may not be used by the
> Session
> implementation, but isn't it possible to tie cookies to a particular
> path
> within in a domain? If the session was somehow associated with a path,
> eg.
> the handler root, could different session IDs for different parts of 
> the
> documentation tree simply be kept separate by appropriate use of 
> Handler
> directive in the root of each separate application context. How does 
> the
> existing ApplicationPath option come into this? Never exactly 
> understood
> what it did and thought that it was something related to having
> different
> session contexts? Seems to me that this might be better than fudging
> what
> name the session cookie uses.
>
> On 28/06/2005, at 11:32 PM, Nicolas Lehuen wrote:
>
> > Hi Wayne,
> >
> >  Right now it's not possible, unfortunately. It's not so difficult to
> > do, however, so you can expect it to be included in the next
>  > mod_python release.
> >
> >  If this is really urgent I can provide you a hack which will give 
> you
> > the ability to define the session cookie name using "PythonOption
> > SessionCookieName foobar ". But it will be definitely a hack and will
> > turn you mod_python version into a non-standard one, which is not a
> > good idea. So it's better to wait for the next release if you can do
> > so.
> >
> >  Regards,
> >  Nicolas
> >
> > 2005/6/28, Wayne Pierce < shalofin at gmail.com>:
> >  Is it possible to change the session name mod_python sends?I have a
> > machine where I will be developing several mod_python apps and would
>  > like to keep the sessions separate.
> >
> > However, I have found that each app will use the same session name,
> > which has caused conflicts (especially when I reuse code between
> > apps).
> >
>  > I didn't find anything in the documentation to do this.Thanks,
> >
> > Wayne
> >
> > _______________________________________________
> >  Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> > _______________________________________________
>  > 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