Opened 8 years ago

Closed 8 years ago

#4244 closed (wontfix)

Session modification sensing

Reported by: robert.szefler@… Owned by: adrian
Component: Core (Other) Version: 0.95
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently, the session is saved only when the session object itself is touched (keys are added, deleted, values modified). This is even described as a "gotcha" in the official documentation. How about changing this to sense changes anywhere deep in the session objects?

My scenario is as follows:

request.sessionxxx? = []

then later

request.sessionxxx?.append({'oh':'swell'})

The sensing mechanism could compare the pickled values (this would require storing the original session's pickle somewhere at the start of a request) or hash values to conserve a bit of memory (I guess would be all right for most purposes but not bulletproof).

If the proposal is accepted, I could write a patch.

Change History (2)

comment:1 Changed 8 years ago by robert.szefler@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

The example was of course meant to be:

request.session['xxx'] = []
request.session['xxx'].append({'oh':'swell'})

comment:2 Changed 8 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

That's quite a bit of extra computational work that needs to be done on every single request that uses a session, so for performance reasons I don't think this is worth it.

If you are accessing a deep object, set self.modified on the SessionWrapper instance and it will be saved. Or construct the detailed object first and only assign it to the session when you are happy with it (not always possible, but often is).

Note: See TracTickets for help on using tickets.
Back to Top