Commits

Anonymous committed 501c7a5

Added naming capability to StackedObject for better debugging when a object isn't registered

  • Participants
  • Parent commits 4468b48

Comments (0)

Files changed (1)

File paste/registry.py

     objects can be removed with pop_object. 
     
     """
-    def __init__(self, default=None):
+    def __init__(self, default=None, name="Default"):
         """Create a new StackedObjectProxy
         
         If a default is given, its used in every thread if no other object
         has been pushed on.
         
         """
+        self.__dict__['_name'] = name
         self.__dict__['local'] = threadinglocal.local()
         if default:
             self.__dict__['_default_object'] = default
                 return object
             else:
                 raise TypeError(
-                    "No object has been registered for this thread")
+                    "No object (Name: %s) has been registered for this \
+                    thread" % self.__dict__['_name'])
     
     def push_object(self, obj):
         """Make ``obj`` the active object for this thread-local.