durusmail: quixote-users: SQL-based session persistence techniques.
SQL-based session persistence techniques.
2004-02-22
2004-02-29
2004-03-01
2004-03-05
2004-03-18
SQL-based session persistence techniques.
Neil Schemenauer
2004-03-01
On Sat, Feb 28, 2004 at 08:09:17PM -0800, Titus Brown wrote:
> Attached; it does two things:
>
> * Session.__init__ now takes as arguments (id, remote_addr, create_time=None)
>       and sets creation time to time() by default;
>
> * SessionManager.new_session instantiates session_class with remote_addr
>       directly:
>
>       session = self.session_class(id, request.get_environ('REMOTE_ADDR'))

After further though, I would prefer that the signature of Session
not be changed.  It's possible that some application sessions are
not interested in 'remote_address' or they want to use some other
data in the request when creating sessions (e.g. cookies).

Instead, I propose that the '__remote_address', '__creation_time'
and '__access_time' be renamed to '_remote_address',
'_creation_time', and '_access_time'.

For your case, you could make your session class a new-style class:

    class MySession(object, Session):
        [...]

and to restore it from the DB you can use __new__:

    s = MySession.__new__()
    s.id = ...
    ...

Does that work for you?

  Neil


reply