Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-176

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2.8
    • Fix Version/s: 3.3.1
    • Component/s: None
    • Labels:
      None

      Description

      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.

        Activity

        Hide
        grahamd Graham Dumpleton added a comment -

        Fixed, but did not deal with issue of autosaving. That can be revisited later if it ever becomes a problem.

        Show
        grahamd Graham Dumpleton added a comment - Fixed, but did not deal with issue of autosaving. That can be revisited later if it ever becomes a problem.

          People

          • Assignee:
            grahamd Graham Dumpleton
            Reporter:
            grahamd Graham Dumpleton
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development