durusmail: quixote-users: Session persistence for Quixote 2.0
Session persistence for Quixote 2.0
2005-05-26
2005-05-27
2005-05-27
2005-05-27
2005-05-27
2005-05-27
2005-05-27
2005-05-27
2005-05-28
2005-05-29
2005-05-29
2005-05-29
2005-05-28
2005-05-28
2005-05-29
2005-05-29
Sessions in mod_python (was [Quixote-users] Session persistence...
2005-05-29
Session persistence for Quixote 2.0
Mike Orr
2005-05-29
Michele Simionato wrote:

>This is just to ask if somebody here has experience with session management
>in mod_python and if we could borrow ideas/code from it (for instance about
>the locking mechanism). I have heard people saying sessions in mod_python
>work fine, so I wanted to know if this was a general impression. This is
>the relevant page in the documentation:
>
>http://www.modpython.org/live/current/doc-html/pyapi-sess.html
>
>             Michele Simionato
>_______________________________________________
>Quixote-users mailing list
>Quixote-users@mems-exchange.org
>http://mail.mems-exchange.org/mailman/listinfo/quixote-users
>
>

I haven't used mod_python, but here's the locking code.  It seems to be
a wrapper around an Apache locking feature.  It all looks very
Apache-specific, possibly useful for mod_scgi but not much elsewhere.

# --- mod_python/Session module --
class BaseSession(dict):
    def __init__(self, ..., lock=1, ...):
        self._lock = lock
        self._locked = 0
        ...
        self.init_lock()
        if self._sid:    # Session ID.
            self.lock()
            ...
        if self._new:
            # Unlock old ._sid, create session, unlock new ._sid.

    def __del__(self):
        self.unlock()

    def init_lock(self):
        pass

    def lock(self):
        if self._lock:  # Using DBM sessions rather than memory sessions.
            _apache._global_lock(self._req.server, self._sid)
           self._locked = 1
           ...

# --- _apachemodule.c ---
.._global_lock is a C method that calls:
    apr_pool_userdata_get
    apr_global_mutex_lock
reply