Django

Code

Show
Ignore:
Timestamp:
02/25/08 00:02:35 (11 months ago)
Author:
gwilson
Message:

Fixed #5701 -- Fixed decorators to take the name, attributes, and docstring of the function they decorate by adding a modified version of the functools.wraps function from Python 2.5. wraps has been altered to work with Django's curry function and with Python 2.3, which doesn't allow assignment of a function's __name__ attribute. This fixes severaly annoyances, such as the online documentation for template filters served by the admin app. This change is backwards incompatible if, for some reason, you were relying on the name of a Django decorator instead of the function it decorates.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/utils/decorators.py

    r5631 r7153  
    22 
    33import types 
     4try: 
     5    from functools import wraps 
     6except ImportError: 
     7    from django.utils.functional import wraps  # Python 2.3, 2.4 fallback. 
    48 
    59def decorator_from_middleware(middleware_class): 
     
    5458                    return result 
    5559            return response 
    56         return _wrapped_view 
     60        return wraps(view_func)(_wrapped_view) 
    5761    return _decorator_from_middleware