Opened 17 years ago

Closed 17 years ago

#5507 closed (fixed)

File bases session backend failing on Win32

Reported by: dougn Owned by: Philippe Raoult
Component: Contrib apps Version: dev
Severity: Keywords: sessions, file backend
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The new file based Session backend (ticket #2066, changeset [6333]) fails on Win23 due to the SESSION_FILE_PATH defaulting to '/tmp/'

django/trunk/django/conf/global_settings.py should get the default using the environ for the temporary storage on Win32/OSX

Adding the following to your local test settings file will work as a temporary workaround:

SESSION_FILE_PATH = os.environ['TMP']

Test Failure:

======================================================================
FAIL: Doctest: django.contrib.sessions.tests
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\django-sprint\trunk\django\test\_doctest.py", line 2169, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for django.contrib.sessions.tests
  File "C:\django-sprint\trunk\django\contrib\sessions\tests.py", line 0, in tests

----------------------------------------------------------------------
File "C:\django-sprint\trunk\django\contrib\sessions\tests.py", line 35, in django.contrib.sessions.tests
Failed example:
    file_session.exists(file_session.session_key)
Expected:
    True
Got:
    False


----------------------------------------------------------------------
Ran 165 tests in 291.149s

FAILED (failures=1)

Attachments (2)

5507.diff (1.1 KB ) - added by Philippe Raoult 17 years ago.
updated for latest revision
5507_simple.diff (2.1 KB ) - added by Philippe Raoult 17 years ago.
better patch, even has docs!

Download all attachments as: .zip

Change History (13)

comment:1 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Philippe Raoult, 17 years ago

Component: Unit test systemContrib apps
Has patch: set
Owner: changed from nobody to Philippe Raoult
Status: newassigned

attached patch fixes the issue. Tested under windows and linux, but should be portable due to the use of tempfile.gettempdir().

comment:3 by dougn, 17 years ago

I fear there might be a meta-bug in here. The failure to create the session file should have resulted in an error, not the test returning 'False' when checking to see if there is a session. The real error (which could be permission based, or even typo based), is lost somewhere. I see this as being the equivalent to not having the table created in teh database, which gives an appropriate backend exception.

comment:4 by Brantley, 17 years ago

Yeah, I agree. In the meanwhile, I suggest commiting this patch asap so that tests can continue to be run on Windows.

in reply to:  4 comment:5 by allandouglas@…, 17 years ago

Replying to deadwisdom:

Yeah, I agree. In the meanwhile, I suggest commiting this patch asap so that tests can continue to be run on Windows.

Please commit it.

by Philippe Raoult, 17 years ago

Attachment: 5507.diff added

updated for latest revision

comment:6 by Philippe Raoult, 17 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Alex Gaynor, 17 years ago

gettempdir()'s return doesn't have the trailing slash(on linux at least it returns '/tmp') would this be a problem?

comment:8 by Malcolm Tredinnick, 17 years ago

Needs documentation: set
Patch needs improvement: set
Triage Stage: Ready for checkinAccepted
  1. Imports don't belong in the middle of files. They go at the top.
  2. Instead of importing tempfile unconditionally in settings.py, when it's only needed for the file-based session backend, let's have that setting default to None which will mean "at use time, it will be converted to the tmp directory's location" and then we can pick the right value in django.contrib.session.backends.file. We try fairly hard to avoid importing unneeded modules that are only going to be used rarely and this is one of those cases.

comment:9 by Philippe Raoult, 17 years ago

Patch needs improvement: unset

Followed malcolm's guidance.

Alex: no the backend uses os.path.join so it will be added as/if needed.

by Philippe Raoult, 17 years ago

Attachment: 5507_simple.diff added

better patch, even has docs!

comment:10 by Philippe Raoult, 17 years ago

Needs documentation: unset
Triage Stage: AcceptedReady for checkin

comment:11 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: assignedclosed

(In [7329]) Fixed #5507 -- Use a more portable way to get at the system's tmpdir (fixes a
problem with the default on Windows). Thanks, Philippe Raoult.

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