Grisha wrote .. > > On Mon, 13 Mar 2006, Graham Dumpleton wrote: > > > Thus I want a documented convention that if a handler is going to use > > util.FieldStorage, that it should before doing so, first check whether > > an existing instance resides as req.form and use that instead. > > I'm not sure if this is a good example - req.form is something specific > to > the publisher. Rather than perhaps documenting it as you suggest, > util.FieldStorage can take it upon itself to create a req.form so that > subsequent attempts to instantiate it just return req.form. (This is just > an example, I'm not 100% sure that I having FS do this makes sense - seems > like a good idea). > > > Similarly, if a handler is going to create a Session object, that it > > look for an existing instance as req.session and again use that instead. > > OR, the Session module would know to look for a req.session, in which case > the handlers wouldn't need to worry about it. > > (One thing to watch out for would be that mutliple concurrent sessions > in the same request is a possibility)
Hmmm, having a look at the code, at some point the check for req.session got added and I didn't realise or forgot that it had been done. # does this code use session? session = None if "session" in code.co_names: if hasattr(req, 'session'): session = req.session else: session = Session.Session(req) It didn't get added for form though, which means that accessing form arguments from within a PSP page will mean only those in the query string of the URL will be available as the content of the request has already been consumed. Looks like a audit of both: https://issues.apache.org/jira/browse/MODPYTHON-38 https://issues.apache.org/jira/browse/MODPYTHON-59 need to be done to work out what has and hasn't been done related to this so we know where we are up to. Looks a bit like when the req.get_session() changes got rolled back that it got introduced at that point: http://svn.apache.org/viewcvs.cgi//httpd/mod_python/trunk/lib/python/mod_python/psp.py?rev=226320&view=diff&r1=226320&r2=226319&p1=/httpd/mod_python/trunk/lib/python/mod_python/psp.py&p2=/httpd/mod_python/trunk/lib/python/mod_python/psp.py Before the req.get_session() change it didn't exist: http://svn.apache.org/viewcvs.cgi//httpd/mod_python/trunk/lib/python/mod_python/psp.py?rev=191745&view=diff&r1=191745&r2=191744&p1=/httpd/mod_python/trunk/lib/python/mod_python/psp.py&p2=/httpd/mod_python/trunk/lib/python/mod_python/psp.py I can't remember if this was a conscious decision to check for req.session based on suggestions or otherwise. Graham