summaryrefslogtreecommitdiff
path: root/paste/registry.py
diff options
context:
space:
mode:
authorbbangert <devnull@localhost>2009-02-08 22:05:01 +0000
committerbbangert <devnull@localhost>2009-02-08 22:05:01 +0000
commit244509d7d4ce21b51d44becaab853b8b522ca92a (patch)
treea6f8f1f4aea02a24b937daffe076b4a7249ffc9c /paste/registry.py
parent417afb105e3d5d8a57ef013d1cd708b371755855 (diff)
downloadpaste-244509d7d4ce21b51d44becaab853b8b522ca92a.tar.gz
Speed tweak to registry access
Diffstat (limited to 'paste/registry.py')
-rw-r--r--paste/registry.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/paste/registry.py b/paste/registry.py
index fba1822..1b40255 100644
--- a/paste/registry.py
+++ b/paste/registry.py
@@ -209,9 +209,11 @@ class StackedObjectProxy(object):
module.glob._pop_object(conf)
"""
- if not hasattr(self.____local__, 'objects'):
+ try:
+ self.____local__.objects.append(obj)
+ except AttributeError:
self.____local__.objects = []
- self.____local__.objects.append(obj)
+ self.____local__.objects.append(obj)
def _pop_object(self, obj=None):
"""Remove a thread-local object.
@@ -220,14 +222,15 @@ class StackedObjectProxy(object):
error is emitted if they don't match.
"""
- if not hasattr(self.____local__, 'objects'):
+ try:
+ popped = self.____local__.objects.pop()
+ if obj:
+ if popped is not obj:
+ raise AssertionError(
+ 'The object popped (%s) is not the same as the object '
+ 'expected (%s)' % (popped, obj))
+ except AttributeError:
raise AssertionError('No object has been registered for this thread')
- popped = self.____local__.objects.pop()
- if obj:
- if popped is not obj:
- raise AssertionError(
- 'The object popped (%s) is not the same as the object '
- 'expected (%s)' % (popped, obj))
def _object_stack(self):
"""Returns all of the objects stacked in this container