瀏覽代碼

Proxy now supports __name__ and __doc__.

Ask Solem 13 年之前
父節點
當前提交
1d3d77f9b9
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      celery/local.py

+ 12 - 1
celery/local.py

@@ -32,7 +32,18 @@ class Proxy(object):
 
     def __init__(self, local, name=None):
         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):
         """Return the current object.  This is useful if you want the real