R: [mod_python] Session instances can't be stored in req?

Manera, Villiam vmanera at manord.com
Fri Nov 7 12:23:34 EST 2003


I had a similar problem, not exactly I now show it but for explain:

def xxx(req):
	sess = Session(req)
	...
	req.sess = sess
	return yyy(req)

def yyy(req):
	sess = check_sess()

def check_sess(req):
	if hasattr(req,'sess'):
		sess = req.sess
	else:
		sess = Session(req)
	return sess

this hang apache

if I delete the attribut from req all work fine:

def check(req):
	if hasattr(req,'sess'):
		sess = req.sess
		delattr(req,'sess')
	else:
		sess = Session(req)
	return

I think in this way:

class BaseSession(dict):
	...
	def __del__(self):
        self.unlock()

the del unlock apache

where have you put the  fixuphandler(req) and who call it? I'm interisting
in it too

Villiam



-----Messaggio originale-----
Da: Stian Søiland [mailto:stian at soiland.no]
Inviato: venerdì 7 novembre 2003 11.37
A: mod_python at modpython.org
Oggetto: [mod_python] Session instances can't be stored in req?


Again with 3.1.2b..

I've gone a bit tired of creating the session objects on every page, so
I made a fixuphandler to do the trick. The problem is, Apache hangs for
infinity:

def fixuphandler(req):
    # req.session = Session(req)
    sezz = Session(req)
    req.blapp = str(id(sezz))
    req.blupp = sezz
    open("/tmp/faentosk", "w")
    return apache.OK


Within index.py:  (result is a html document)

try:
    result.add(req.blapp)
    result.add(str(id(req.blupp)))
    result.add(str(req.sezz))
except Exception, e:
    result.add(str(e))

Now, if I don't save the session instance (the sezz) - everything works. If
I
try to store sezz in req.blupp - everything fails - the apache process
hangs,
the file /tmp/faentosk is never created, ie. everything stops at the
previous line.

I've tried making a Dummy class and instanciating it instead, sezz =
Dummy() - and writing out the id in same way, works like a charm, and
the id confirms that it's the same object instanciated within
fixuphandler.

Any tip?

-- 
Stian Søiland               Work toward win-win situation. Win-lose
Trondheim, Norway           is where you win and the other lose.
http://www.soiland.no/      Lose-lose and lose-win are left as an
                            exercise to the reader.  [Limoncelli/Hogan]

_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list