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
[email protected]
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
_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users

Reply via email to