web开发 Django开发交流群:19525555 注册 | 登陆

Django session file 无法保存数据问题

原来这个是python的bug

This is a bug of save() function of django.contrib.sessions.backends.file.SessionStore? class. On Windows, os.rename function of Python will raise OSError if the destination file already exists. Whereas on Unix, it will be removed silently. To fix this problem, remove the existing file before renaming if the current operating system is Windows. 

根据这个,就得修改下源代码了

django/contrib/sessions/backends/file.py

122 行 加入下面代码的前两行

XML/HTML代码
  1. if os.name == "nt":  
  2.     os.unlink(session_file_name)  
  3.   
  4. os.rename(output_file_name, session_file_name)  
  5. renamed = True  
这个问题应该在1.1版本会解决,不过我还没有去看具体代码

 

Tags: django

« 上一篇 | 下一篇 »

只显示10条记录相关文章

[转] Django 调试 (浏览: 336, 评论: 1)
Django遍历输出字典key,value (浏览: 899, 评论: 4)
使用django forms 实现无限分级 (浏览: 544, 评论: 1)
Django 内置分页类 (浏览: 816, 评论: 0)
Django settings.py 配置必须大写 (浏览: 553, 评论: 0)
django在模板获取当前用户 (浏览: 546, 评论: 0)
Django 输出sql语句 (浏览: 747, 评论: 0)
Django模板使用全局变量 (浏览: 724, 评论: 1)
Windows环境下配置 Apache2+MySQL+mod_python+Django (浏览: 1497, 评论: 0)
有关Django性能优化总结 (浏览: 808, 评论: 0)

Trackbacks

点击获得Trackback地址,Encode: UTF-8

1条记录访客评论

学习了

http://www.tjpf120.com

Post by 白癜风 on 2010-07-31, 14:07:30 引用此文发表评论 #1


发表评论

评论内容 (必填):