OK then I'm OK if you check your code. We'll fix this later, and
anyway if someone has a custom session implementation, he is already
using it wihout get_session() so there won't be any regression of his
code.
Regards,
Nicolas
2005/6/15, Jim Gallacher <[EMAIL PROTECTED]>:
> Nicolas Lehuen wrote:
> > Jim, just one question. Suppose I write a home-made session
> > implementation, myownsessionmodule.MyOwnSession. How would I configure
> > this using PythonSessionOption ? I see there is no problem for
> > paramaters (the different session classes use whatever session
> > parameter they need), but will I be able to write this :
> >
> > PythonSessionOption session myownsessionmodule.MyOwnSession
>
> Currently, for testing purposes req.get_session() calls
> mod_python.Session.create_session() which looks like this:
>
> Session.py
> ----------
>
> def create_session(req,sid):
> opts = req.get_session_options()
> session_type = opts['session']
> if session_type == 'FileSession':
> return FileSession(req,sid)
> elif session_type == 'DbmSession':
> return DbmSession(req,sid)
>
> ... and so on
>
> Not pretty but it works.
>
> > That is to say, are you using this parameter as the class name, in
> > which case your example should be :
> > PythonSessionOption session Session.FileSession
> >
> > and not
> >
> > PythonSessionOption session FileSession
> >
> > Or are you looking for the class in the Session module, thus
> > forbidding other implementations to step in ?
>
> As create_session() is currently implemented only known sessions classes
> are allowed, but it should be easy to change it to load a module
> instead. Python is a dynamic language after all.
>
> Regards,
> Jim
>
> > Regards,
> > Nicolas
> >
> >
> > 2005/6/15, Jim Gallacher <[EMAIL PROTECTED]>:
> >
> >>So, any further thoughts / comments / objections to PythonSessionOption,
> >> or shall I just check in the code?
> >>
> >>Regards
> >>Jim
> >>
> >>
> >>Jim Gallacher wrote:
> >>
> >>>I've created a new apache directive called PythonSessionOption. This
> >>>would be used to configure session handling in the apache config file.
> >>>This data is accessed with a new request method, req.get_session_options().
> >>>
> >>>Although we could use the PythonOption directive instead of creating a
> >>>new one, I believe it's better to keep the session config data separate
> >>>so we don't need to worry about collisions with current user code or
> >>>configuration.
> >>>
> >>>Typical Usage
> >>>-------------
> >>>
> >>>In a test script mptest.py
> >>>
> >>>def handler(req)
> >>> opts = req.get_session_options()
> >>> for k in sess_conf:
> >>> req.write('%s: %s' % (k,opts[k])
> >>>
> >>>
> >>>In Session.FileSession:
> >>> __init__(self,req,sid):
> >>> opts = req.get_session_options()
> >>> timeout = int(opts.get('timeout', DFT_TIMEOUT))
> >>>
> >>>
> >>>In an Apache config file:
> >>>
> >>><VirtualHost 192.168.1.12:80>
> >>> ServerAdmin [EMAIL PROTECTED]
> >>> ServerName example.com
> >>> DocumentRoot /var/www/
> >>>
> >>> PythonSessionOption session FileSession
> >>> PythonSessionOption session_directory /var/lib/mod_python/sess
> >>> PythonSessionOption timeout 14400
> >>> PythonSessionOption lock 1
> >>>
> >>> ...
> >>></VirtualHost>
> >>>
> >>>If there are no objections I'll commit the code. I have not refactored
> >>>Sessions.py to use the new configuration scheme just yet.
> >>>
> >>>Regards,
> >>>Jim
> >>>
> >>
> >>
> >
>
>