Issue Details (XML | Word | Printable)

Key: MODPYTHON-176
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Graham Dumpleton
Reporter: Graham Dumpleton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

PSP.run() should not unlock session if it didn't create it.

Created: 27/Jun/06 06:31 PM   Updated: 01/May/07 10:34 AM
Return to search
Component/s: None
Affects Version/s: 3.2.8
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

Resolution Date: 29/Jul/06 12:24 PM


 Description  « Hide
When PSP.run() is exiting, it unlocks the session even if it had not created the session object in the first place. In other words, it still unlocks the session if it was inherited by using that already stored as req.session.

By rights it should not unlock the session object when it is inherited from req.session as that causes limitations when PSP objects are being used explicitly as a templating system from publisher or other handlers. Specifically, it would prevent the handler which used the PSP object making changes to the session object after PSP.run() has been called and then doing a subsequent save of the session.

That session locks should not perhaps be unlocked by PSP.run() was first mentioned in MODPYTHON-38. Note that the session still gets unlocked, but by a cleanup handler registered by the session object when it was first created.

At the same time, it could be said that PSP.run() shouldn't call save on the session automatically when the session object is inherited and that the save should be left up to the handler making use of the PSP object in these situations. Existing use of the PSP objects would need to be evaluated to determine if disabling autosave would cause issues for existing code if such a change were to be made for when session object inherited. A better option may be to add an additional argument run PSP.run() called autosave which defaults to True to preserve existing behaviour, but allow explicit users of PSP objects to change the behaviour if required. This all gets a bit complicated when error pages come into the picture though, so more thought needed on this latter point of autosave.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Graham Dumpleton made changes - 29/Jul/06 11:27 AM
Field Original Value New Value
Assignee Graham Dumpleton [ grahamd ]
Graham Dumpleton made changes - 29/Jul/06 11:27 AM
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton added a comment - 29/Jul/06 12:24 PM
Fixed, but did not deal with issue of autosaving. That can be revisited later if it ever becomes a problem.

Graham Dumpleton made changes - 29/Jul/06 12:24 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Fix Version/s 3.3 [ 12310101 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #426788 Sat Jul 29 12:25:06 UTC 2006 grahamd (MODPYTHON-175) Fixed problem whereby a main PSP page and an error page
triggered from that page both accessing the session object would cause a
deadlock.

(MODPYTHON-176) Fixed issue whereby PSP code would unlock session object
which it had inherited from the caller meaning caller could no longer use
it safely. PSP code will now only unlock session if it created it in the
first place.
Files Changed
ADD /httpd/mod_python/trunk/test/htdocs/psptest_main.psp
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/psp.py
ADD /httpd/mod_python/trunk/test/htdocs/psptest_fail.psp
MODIFY /httpd/mod_python/trunk/test/test.py
MODIFY /httpd/mod_python/trunk/Doc/appendixc.tex

Graham Dumpleton made changes - 01/May/07 10:34 AM
Status Resolved [ 5 ] Closed [ 6 ]