0
votes

What is the difference in functionality between from django.utils.functional import wraps and from functools import wraps?

i m using django 1.3 and python 2.4.i want to remove sensitive information from post data but django.views.decorators.debug is available only in django 1.4.So i copy the source code and put in my project from https://bitbucket.org/orzel/django-1.4-production/src/507b10c2c0e3/django/views/decorators/debug.py. but this decorator uses functools which is not available in python 2.4.so i use django.utils.functional import wraps instead of from functools import wraps.But still the sensitive info appear in error mail? any suggestions?

2

2 Answers

1
votes

I don't think there is a difference. It is probably a backport for older Python versions which don't support functools.wraps.

Edit

Actually since latest Django does not support any Python version anymore which does not support functools I think its just left there for possible dependency issues (in Django or in Django projects). It is actually even importing functools.wraps directly now: http://code.djangoproject.com/svn/django/trunk/django/utils/functional.py

1
votes

This was implemented 5 years ago to fix naive introspection using Django Decorators:

http://code.djangoproject.com/ticket/5701

Read the bug details for the motivation behind it.

It was used like:

try:
    from functools import wraps
except ImportError:
    from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.