﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5701	Fix naive introspection when using Django decorators	Jeremy Dunck	nobody	"It's fairly well-known that decorators are useful, but raise some issues.

Example:
==============
def decorate(f):
   def wrap(*args, **kwargs):
       print ""called""
       return f(*args, **kwargs)
   return wrap

@decorate
def add_to(augend, addend):
   ""Adds stuff""
   return augend + addend

Introspecting add_to, undecorated, would have a __name__ of 'add_to'
and __doc__ of 'Adds stuff'.

After decorating, add_to.__name__ becomes 'wrap' and __doc__ becomes None.

================

In Python 2.5+, there's functools.wraps, which takes care of the
problem of introspection on decorated functions by copying attributes
from the wrapped function.

http://docs.python.org/lib/module-functools.html

Django already includes curry, which is roughly the same as
functools.partial, so it's pretty easy to implement functools.wraps.

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."		new	Uncategorized	dev			decorators views		Unreviewed	1	0	0	0	0	0
