On Thu, May 27, 2010 at 7:13 PM, Philipp <philipp.knue...@gmail.com> wrote:

> Hello Django Users
>
> I'm a beginner going through the tutorial. I do have a problem using
> the admin interface.
> I can't add new records. Save results in: http://dpaste.de/UoBH/
> If I'm using the shell, everything works fine: http://dpaste.de/q5O0/
>

The end of the traceback is:

File
"/usr/lib/python2.4/site-packages/django/contrib/messages/storage/cookie.py",
line 128, in _encode
return '%s$%s' % (self._hash(value), value)

File
"/usr/lib/python2.4/site-packages/django/contrib/messages/storage/cookie.py",
line 115, in _hash
return hmac.new(key, value, sha_hmac).hexdigest()

File "/usr/lib/python2.4/hmac.py", line 107, in new
return HMAC(key, msg, digestmod)

File "/usr/lib/python2.4/hmac.py", line 42, in __init__
self.outer = digestmod.new()

AttributeError: 'builtin_function_or_method' object has no attribute 'new'

Googling that error message and hmac reveals other projects that have run
afoul of this problem, which seems to result from code that tries to rely on
the results of "import hashlib" to determine whether the code is running
with a Python 2.5-level hashlib or needs to fall back to using the older
Python 2.4 md5/sha modules instead.

The problem arises when the standalone hashlib module available on PyPI is
installed on Python 2.4 ... though "import hashlib" then works, subsequent
code that attempts to use the hashlib routines and hmac together run into
trouble because the way the 2.4 hmac module calls the hashlib routines is
different from the way 2.5 does...so the 2.4-level hmac calls into the 2.5
level hashlib in a way that blows up.

So, this sounds like a bug in Django that will affect people running Python
2.4 + standalone hashlib. The sole import of hmac in Django is in that
contrib/messages/storage/cookie.py file, which is new in 1.2 so I believe
this is a new problem for 1.2.

Workarounds for you prior to getting a fix into Django would be to get rid
of the standalone hashlib that's apparently installed, or use a more recent
level of Python.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to