1

每次尝试登录我的 Django 站点的本地副本时,我都会收到以下错误:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/users/process_login/

Django Version: 1.4
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'tweets',
 'users',
 'dashboard',
 'GChartWrapper.charts',
 'api',
 'prospector',
 'viz')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/sheldonc/Tealeaf/users/views.py" in process_login
  184.             login(request, user)
File "/Library/Python/2.7/site-packages/django/contrib/auth/__init__.py" in login
  71.         request.session.cycle_key()
File "/Library/Python/2.7/site-packages/django/contrib/sessions/backends/base.py" in cycle_key
  241.         self.create()
File "/Library/Python/2.7/site-packages/mongoengine-0.6.1-py2.7.egg/mongoengine/django/sessions.py" in create
  44.             self.session_key = self._get_new_session_key()

Exception Type: AttributeError at /users/process_login/
Exception Value: can't set attribute

和异常位置:

Exception Location: /Library/Python/2.7/site-packages/mongoengine-0.6.1-py2.7.egg/mongoengine/django/sessions.py in create, line 44

使用 pdb,我进一步调试了它。在login(request, user)方法中:

def login(request, user):
 56         """
 57         Persist a user id and a backend in the request. This way a user doesn't
 58         have to reauthenticate on every request. Note that data set during
 59         the anonymous session is retained when the user logs in.
 60         """
 61         if user is None:
 62             user = request.user
 63         # TODO: It would be nice to support different login methods, like signed cookies.
 64         if SESSION_KEY in request.session:
 65             if request.session[SESSION_KEY] != user.id:
 66                 # To avoid reusing another user's session, create a new, empty
 67                 # session if the existing session corresponds to a different
 68                 # authenticated user.
 69                 request.session.flush()
 70         else:
 71             request.session.cycle_key()

SESSION_KEY是 None ,所以request.session.cycle_key()被称为,并且在那里的某个地方出现了 AttributeError 被抛出(

这是我的 mongo 连接的问题吗?我一直在四处寻找,但我似乎无法弄清楚

4

1 回答 1

0

已知(并已修复)错误:https ://github.com/hmarr/mongoengine/issues/469

于 2012-06-30T10:57:17.490 回答