Django基于文件的会话 - 文件名太长

时间:2012-05-22 13:55:35

标签: python django django-sessions

我正在使用Django == 1.1(我必须)
和基于文件的会话。我得到跟踪追溯(下面)

我知道在django.contrib.sessions.backends.file.SessionStore初始化期间,构造函数的session_key非常长。 但是这个类实例的创建地点 - 我不知道。我想知道。为什么会创建这么长的session_key?

Traceback (most recent call last):
  File "/Users/john/.virtualenvs/app/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 279, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/john/.virtualenvs/app/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 651, in __call__
    return self.application(environ, start_response)
  File "/Users/john/.virtualenvs/app/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 245, in __call__
    response = middleware_method(request, response)
  File "/Users/john/.virtualenvs/app/lib/python2.7/site-packages/django/contrib/sessions/middleware.py", line 36, in process_response
    request.session.save()
  File "/Users/john/.virtualenvs/app/lib/python2.7/site-packages/django/contrib/sessions/backends/file.py", line 88, in save
    fd = os.open(session_file_name, flags)
OSError: [Errno 63] File name too long: '/tmp/sessionid.eJydVktv4zYQ9m63Fx7aQ3-EfXJFvYWeit1FkYuLrpNuDwsQlMTQSmRJJqU4KVCgP70zQ8mPxMmhB8kWh5z55psX_33_z-7d4uaDaWv11_ez2UyW26rZvb_5wQpTVo224raUvdx9d_3Tu9lsUXacrefNsM2VEfmcdT5b2fXc9tL0AjaqvtoqWA5YMX2xw58uZIv1_Nujl3x7LAv4jeDh8HiXnjkruqf-byY61kV48PNg2k79_FUaK_dgI2ZXie957CqI4b2ef_y8voblhPVfuhRfGbMHrBIkHPb6foCrqilP4XLO9AVwHJ_kl5fINOnnPrPLmx-PTFV1r8zuw_VvbDYrirZ7EkZpBq-ibWxvhqJvDRhji6K8k41ul2W-3Lalqu3S7urlblDmif1BbyC2ECIfQGXVCMHa_E4VPRK7AsuAtQRS1nOpNZgAR4RVNWwQW2nviRsMi3ghLmSxUUQSytVjb5CYlOkTUENfASCMusM8GGXZuj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oAaRuoRNU7Wl6jdaOU4W19HnV1AHVAn4zRaL6N2odVnUa4xyvr1kL5-65viAQMcPIOpffQMh3d-8hmdf8aud2wqvZl6NQ_cJczdGkVlBcyk4v6JRKnzPl8Oy_8ACepvHw:1SWRxQ:eJ6zYlFnV8NFqaM2mjeYJUjvBlM'
[22/May/2012 15:45:43] "GET /login/ HTTP/1.1" 500 2736

1 个答案:

答案 0 :(得分:1)

request.session中构建SessionMiddleware.process_request,您可以签入文件django/contrib/sessions/middleware.py。在早期版本中,(刚刚在最近的Django中检查它仍然易受攻击),在触及后端之前,很少检查request.COOKIES中的传入会话密钥,因此你有一个过长的失败{{1} }。