Nathan R. Yergler wrote:
> In looking at the documentation and doing a Google search, I've been
> unable to find any information on implementing sessions with mod_python
I have been trying to do the same thing. I have a database app that I
am using apache+quixote as a front-end for. Because I can't guarantee
that the same apache process would always respond to each subsequent
request, I decided to use the database for session management.
I wrote a trivial little mapper over a database table (it works -- I
have tested all the functions from the interactive prompt), and then
subclassed the session classes as follows:
class SessionManager(quixote.session.SessionManager):
def abort_changes(self, session):
self.sessions.abort()
def commit_changes(self, session):
self.sessions.commit()
class Session(quixote.session.Session):
def __init__(self, request, id):
quixote.session.Session.__init__(self, request, id)
self.mm_data = {}
self.__dirty = 0
def set_user(self, user):
self.user = user
self.real_user = user
self.__dirty = 1
def set_data(self, data):
self.mm_data = data
self.__dirty = 1
def has_info(self):
return 1
def is_dirty(self):
value = self.__dirty
self.__dirty = 0
return value
I tested all the session classes via the session_demo.cgi script and
they all worked perfectly.
I then modified the mod_python publisher by making it subclass
SessionPublisher instead of Publisher. Finally, I changed the handler
function:
def handler(req):
opts = req.get_options()
try:
package = opts['quixote-root-namespace']
except KeyError:
package = None
if not package:
return apache.HTTP_INTERNAL_SERVER_ERROR
else:
pub = name2publisher.get(package)
if pub is None:
pub = ModPythonSessionPublisher(package,
session_mgr=local_session_mgr)
pub.setup_logs()
name2publisher[package] = pub
return pub.publish_modpython(req)
This appears to load, but creates no output (urllib returns an empty
string). I have tried to just replace the handler on the demo -- not
even using any of the session stuff -- but still no dice.
Does someone know what is wrong?
Thanks,
VanL