#19254 closed Bug (fixed)
clear_expired for Sessions With File Backend Throws Exception
Reported by: | Simon Blanchard | Owned by: | nobody |
---|---|---|---|
Component: | contrib.sessions | Version: | 1.5-alpha-1 |
Severity: | Release blocker | Keywords: | sessions filebackend |
Cc: | bnomis@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
The following line in clear_expired for file based sessions does not do what the author intended:
storage_path = getattr(settings, "SESSION_FILE_PATH", tempfile.gettempdir())
tempfile.gettempdir() will only be called if SESSION_FILE_PATH does not exist in settings. But it does exist and defaults to None. The exception occurs in the call os.listdir(storage_path).
What is probably required is this:
storage_path = getattr(settings, "SESSION_FILE_PATH", None) if not storage_path: storage_path = tempfile.gettempdir()
or this:
storage_path = cls._get_storage_path()
Change History (5)
comment:1 by , 12 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 12 years ago
Cc: | added |
---|
comment:3 by , 12 years ago
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Good catch — that's why I factored out
_get_storage_path
! And I forgot to use it in the final patch :(This mistake wasn't caught because Django forces the value of
SESSION_FILE_PATH
in order to be able to clean up after the tests.