diff options
| author | bbangert <bbangert@localhost> | 2006-03-10 20:01:39 +0000 |
|---|---|---|
| committer | bbangert <bbangert@localhost> | 2006-03-10 20:01:39 +0000 |
| commit | 439568ec48b3f78a8363504fa12850aa20c4c6e2 (patch) | |
| tree | 9e94a61d0d7b99d0d6f3e6a5e9313d353827a19d /paste/registry.py | |
| parent | 648d5a53c2071e224e1a8c74c52f03486a5289fb (diff) | |
| download | paste-git-439568ec48b3f78a8363504fa12850aa20c4c6e2.tar.gz | |
Adding registry unit tests, fixed registry to not use weakref's so any object can be proxied (including dicts)
Diffstat (limited to 'paste/registry.py')
| -rw-r--r-- | paste/registry.py | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/paste/registry.py b/paste/registry.py index 350a45e..6a84c43 100644 --- a/paste/registry.py +++ b/paste/registry.py @@ -45,7 +45,6 @@ the calling stack below it and be assured that it is using the object you registered with Registry. """ -import weakref import paste.util.threadinglocal as threadinglocal from paste import wsgilib @@ -64,10 +63,10 @@ class StackedObjectProxy(object): """ def __init__(self): - self.local = threadinglocal.local() + self.__dict__['local'] = threadinglocal.local() def current_obj(self): - objects = getattr(self.local, 'objects', None) + objects = getattr(self.__dict__['local'], 'objects', None) if objects: return objects[-1] else: @@ -151,21 +150,11 @@ class Registry(object): def register(self, stacked, obj): stacked.push_object(obj) myreglist = self.reglist[-1] - myreglist[id(stacked)] = (weakref.ref(stacked), weakref.ref(obj)) + myreglist[id(stacked)] = (stacked, obj) def cleanup(self): for id, val in self.reglist[-1].iteritems(): stacked, obj = val - stacked = stacked() - obj = obj() - if not stacked and not obj: - continue - if not stacked: - raise AssertionError( - "The stacked object no longer exists, but the object to be removed does.") - if not obj: - raise AssertionError( - "The object no longer exists, but the stacked object does.") stacked.pop_object(obj) self.reglist.pop() |
