Changes between Version 1 and Version 2 of Ticket #5701
- Timestamp:
- Nov 18, 2007, 11:45:34 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #5701
- Property Triage Stage Unreviewed → Accepted
-
Ticket #5701 – Description
v1 v2 3 3 Example: 4 4 {{{ 5 #!python 5 6 def decorate(f): 6 7 def wrap(*args, **kwargs): … … 14 15 return augend + addend 15 16 }}} 16 Introspecting add_to, undecorated, would have a __name__of 'add_to'17 and __doc__of 'Adds stuff'.17 Introspecting add_to, undecorated, would have a `__name__` of 'add_to' 18 and `__doc__` of 'Adds stuff'. 18 19 19 After decorating, add_to.__name__ becomes 'wrap' and __doc__becomes None.20 After decorating, `add_to.__name__` becomes 'wrap' and `__doc__` becomes None. 20 21 21 22 ================ 22 23 23 In Python 2.5+, there's functools.wraps, which takes care of the24 In Python 2.5+, there's `functools.wraps`, which takes care of the 24 25 problem of introspection on decorated functions by copying attributes 25 26 from the wrapped function. … … 27 28 http://docs.python.org/lib/module-functools.html 28 29 29 Django already includes curry, which is roughly the same as30 functools.partial, so it's pretty easy to implement functools.wraps.30 Django already includes `curry`, which is roughly the same as 31 `functools.partial`, so it's pretty easy to implement `functools.wraps`. 31 32 32 The attached patch implements django.utils.functional.wraps, updates all Django decorators to use it, and includes tests to verify that the fixing-up works.33 The attached patch implements `django.utils.functional.wraps`, updates all Django decorators to use it, and includes tests to verify that the fixing-up works.