#24437: contrib.auth @ 1.8b1 breaks existing projects / applications using
Mongoengine
------------------------------+--------------------------------------
Reporter: silkentrance | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.8beta1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Description changed by silkentrance:
Old description:
> The following changes in django/contrib/auth/__init__.py
>
> {{{
> root@J101829:/tmp# diff dj18a1/contrib/auth/__init__.py
> dj18b1/contrib/auth/__init__.py
> 55a56,62
> > def _get_user_session_key(request):
> > # This value in the session is always serialized to a string, so we
> need
> > # to convert it back to Python whenever we access it.
> > raise Exception(get_user_model())
> > return
> get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
> >
> >
> 96c103
> < if request.session[SESSION_KEY] != user.pk or (
> ---
> > if _get_user_session_key(request) != user.pk or (
> 105c112
> < request.session[SESSION_KEY] = user.pk
> ---
> > request.session[SESSION_KEY] = user._meta.pk.value_to_string(user)
> 161c168
> < user_id = request.session[SESSION_KEY]
> ---
> > user_id = _get_user_session_key(request)
> }}}
>
>
> break existing applications / projects using Mongoengine.
>
> Mongoengine installs a custom MongoUser that is a shim around the actual
> model, which is a mongoengine document. The actual user id is a
> hexadecimal number / string and might not be validated using int(),
> causing the following exception
>
> {{{
> ValidationError at /backend/admin/
> [u'\u201a511a1da669fe60752b000000\u201b Wert muss eine Ganzzahl sein.']
> Request Method: GET
> Request URL: http://XXX/login
> Django Version: 1.8b1
> Exception Type: ValidationError
> Exception Value:
> [u'\u201a511a1da669fe60752b000000\u201b Value must be an int.']
> Exception Location: /usr/local/lib/python2.7/dist-
> packages/django/db/models/fields/__init__.py in to_python, line 969
> Python Executable: /usr/bin/uwsgi-core
> Python Version: 2.7.8
> }}}
>
> I do not know whether django.contrib.auth should make any assumption on
> the actual type of the id, or whether mongoengine should reimplement the
> pk property and delegate to its own version of the Auto field.
New description:
The following changes in django/contrib/auth/__init__.py
{{{
root@J101829:/tmp# diff dj18a1/contrib/auth/__init__.py
dj18b1/contrib/auth/__init__.py
55a56,62
> def _get_user_session_key(request):
> # This value in the session is always serialized to a string, so we
need
> # to convert it back to Python whenever we access it.
> raise Exception(get_user_model())
> return
get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
>
>
96c103
< if request.session[SESSION_KEY] != user.pk or (
---
> if _get_user_session_key(request) != user.pk or (
105c112
< request.session[SESSION_KEY] = user.pk
---
> request.session[SESSION_KEY] = user._meta.pk.value_to_string(user)
161c168
< user_id = request.session[SESSION_KEY]
---
> user_id = _get_user_session_key(request)
}}}
break existing applications / projects using Mongoengine.
Mongoengine installs a custom MongoUser that is a shim around the actual
model, which is a mongoengine document. The actual user id is a
hexadecimal number / string and might not be validated using int(),
causing the following exception
{{{
ValidationError at /backend/admin/
[u'\u201a511a1da669fe60752b000000\u201b Wert muss eine Ganzzahl sein.']
Request Method: GET
Request URL: http://XXX/login
Django Version: 1.8b1
Exception Type: ValidationError
Exception Value:
[u'\u201a511a1da669fe60752b000000\u201b Value must be an int.']
Exception Location: /usr/local/lib/python2.7/dist-
packages/django/db/models/fields/__init__.py in to_python, line 969
Python Executable: /usr/bin/uwsgi-core
Python Version: 2.7.8
}}}
I do not know whether django.contrib.auth should make any assumption on
the actual type of the id, or whether mongoengine should reimplement the
pk property and delegate to its own version of the Auto field.
See here for the bug I filed against mongoengine:
https://github.com/MongoEngine/mongoengine/issues/899
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24437#comment:2>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.670c41a4d4dfd7196c1cffa1a8597a43%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.