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 に答える