Without this patches, all decorated functions __name__ is set to f, which
is not desirable in testing environment where on sometimes want to access
the name of the function under test.
See 
http://wiki.python.org/moin/PythonDecoratorLibrary#CreatingWell-BehavedDecorators.2BAC8.22Decoratordecorator.22


# HG changeset patch
# User Mathieu Clabaut <mathieu.clab...@gmail.com>
# Date 1273752449 -7200
# Node ID 6acd0eed342316b128d4964dfa96d1bc1025a655
# Parent  6117613d0b77301aa6688e4d8f17f34252f2b88a
Make decorators well behaved.
Without this patches, all decorated functions __name__ is set to f, which
is not desirable in testing environment where on sometimes want to access
the name of the function under test.
See http://wiki.python.org/moin/PythonDecoratorLibrary#CreatingWell-BehavedDecorators.2BAC8.22Decoratordecorator.22

diff -r 6117613d0b77 -r 6acd0eed3423 gluon/tools.py
--- a/gluon/tools.py	Wed May 12 14:34:56 2010 -0500
+++ b/gluon/tools.py	Thu May 13 14:07:29 2010 +0200
@@ -1889,6 +1889,8 @@
                     redirect(next)
                 return action(*a, **b)
             f.__doc__ = action.__doc__
+            f.__name__ = action.__name__
+            f.__dict__.update(action.__dict__)
             return f
 
         return decorator
@@ -1910,6 +1912,8 @@
                                  '?_next='+urllib.quote(next))
                 return action(*a, **b)
             f.__doc__ = action.__doc__
+            f.__name__ = action.__name__
+            f.__dict__.update(action.__dict__)
             return f
 
         return decorator
@@ -1938,6 +1942,8 @@
                     redirect(next)
                 return action(*a, **b)
             f.__doc__ = action.__doc__
+            f.__name__ = action.__name__
+            f.__dict__.update(action.__dict__)
             return f
 
         return decorator
@@ -1970,6 +1976,8 @@
                     redirect(next)
                 return action(*a, **b)
             f.__doc__ = action.__doc__
+            f.__name__ = action.__name__
+            f.__dict__.update(action.__dict__)
             return f
 
         return decorator

Reply via email to