Parcourir la source

Proxy now supports __name__ and __doc__.

Ask Solem il y a 13 ans
Parent
commit
1d3d77f9b9
1 fichiers modifiés avec 12 ajouts et 1 suppressions
  1. 12 1
      celery/local.py

+ 12 - 1
celery/local.py

@@ -32,7 +32,18 @@ class Proxy(object):
 
 
     def __init__(self, local, name=None):
     def __init__(self, local, name=None):
         object.__setattr__(self, '_Proxy__local', local)
         object.__setattr__(self, '_Proxy__local', local)
-        object.__setattr__(self, '__name__', name)
+        object.__setattr__(self, '__custom_name__', name)
+
+    @property
+    def __name__(self):
+        try:
+            return object.__getattr__(self, "__custom_name__")
+        except AttributeError:
+            return self._get_current_object().__name__
+
+    @property
+    def __doc__(self):
+        return self._get_current_object().__doc__
 
 
     def _get_current_object(self):
     def _get_current_object(self):
         """Return the current object.  This is useful if you want the real
         """Return the current object.  This is useful if you want the real