Django

Code

Ticket #5507 (closed: fixed)

Opened 10 months ago

Last modified 4 months ago

File bases session backend failing on Win32

Reported by: dougn Assigned to: PhiR
Milestone: Component: Contrib apps
Version: SVN Keywords: sessions, file backend
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

5507.diff (1.1 kB) - added by PhiR on 03/18/08 14:27:30.
updated for latest revision
5507_simple.diff (2.1 kB) - added by PhiR on 03/19/08 15:26:25.
better patch, even has docs!

Change History

09/16/07 04:16:19 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

09/16/07 12:03:11 changed by PhiR

  • owner changed from nobody to PhiR.
  • status changed from new to assigned.
  • has_patch set to 1.
  • component changed from Unit test system to Contrib apps.

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

09/17/07 11:52:56 changed by dougn

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.

(follow-up: ↓ 5 ) 09/19/07 20:17:19 changed by deadwisdom

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 ) 10/01/07 18:59:34 changed by allandouglas@gmail.com

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.

03/18/08 14:27:30 changed by PhiR

  • attachment 5507.diff added.

updated for latest revision

03/18/08 14:28:21 changed by PhiR

  • stage changed from Accepted to Ready for checkin.

03/18/08 14:30:06 changed by Alex

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

03/19/08 11:32:20 changed by mtredinnick

  • needs_better_patch set to 1.
  • stage changed from Ready for checkin to Accepted.
  • needs_docs set to 1.
  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.

03/19/08 15:23:22 changed by PhiR

  • needs_better_patch deleted.

Followed malcolm's guidance.

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

03/19/08 15:26:25 changed by PhiR

  • attachment 5507_simple.diff added.

better patch, even has docs!

03/19/08 15:26:37 changed by PhiR

  • needs_docs deleted.
  • stage changed from Accepted to Ready for checkin.

03/20/08 01:43:59 changed by mtredinnick

  • status changed from assigned to closed.
  • resolution set to fixed.

(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.


Add/Change #5507 (File bases session backend failing on Win32)




Change Properties
Action