Django

Code

Show
Ignore:
Timestamp:
02/25/08 00:02:35 (9 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/template/defaultfilters.py

    r7033 r7153  
    33import re 
    44import random as random_module 
     5try: 
     6    from functools import wraps 
     7except ImportError: 
     8    from django.utils.functional import wraps  # Python 2.3, 2.4 fallback. 
    59 
    610from django.template import Variable, Library 
     
    3640        if hasattr(func, attr): 
    3741            setattr(_dec, attr, getattr(func, attr)) 
    38     return _dec 
     42    return wraps(func)(_dec) 
    3943 
    4044###################