#8616: File-based sessions dropped with SESSION_SAVE_EVERY_REQUEST = True
----------------------------------------------+-----------------------------
          Reporter:  [email protected]    |         Owner:  jacob           
   
            Status:  reopened                 |     Milestone:                  
   
         Component:  django.contrib.sessions  |       Version:  1.1             
   
        Resolution:                           |      Keywords:  session, file, 
race
             Stage:  Unreviewed               |     Has_patch:  1               
   
        Needs_docs:  0                        |   Needs_tests:  0               
   
Needs_better_patch:  0                        |  
----------------------------------------------+-----------------------------
Changes (by wiser0):

  * status:  closed => reopened
  * stage:  Accepted => Unreviewed
  * resolution:  fixed =>
  * version:  SVN => 1.1
  * milestone:  1.0 =>

Comment:

 On Windows (XP) with Python 2.6.3, the session files were always zero
 bytes in length.  I created the following patch:

 {{{
 --- D:/python26/Lib/site-
 packages/django-1.1-py2.6.egg/django/contrib/sessions/backends/file.py Tue
 Oct 20 16:58:59 2009
 +++ D:/python26/Lib/site-
 packages/django-1.1-py2.6.egg/django/contrib/sessions/backends/file_NEW.py
 Tue Oct 20 16:58:34 2009
 @@ -119,6 +119,11 @@
                      os.write(output_file_fd, self.encode(session_data))
                  finally:
                      os.close(output_file_fd)
 +
 +                # On Windows, old file must be removed or rename() will
 fail.
 +                if os.name == 'nt':
 +                    os.unlink(session_file_name)
 +
                  os.rename(output_file_name, session_file_name)
                  renamed = True
              finally:
 }}}

 Apologies if this is not the correct place for this.  It is my first
 attempt at contributing to Django.

 - Randy

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8616#comment:31>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to