diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-10-22 21:44:37 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-10-22 21:44:37 +0000 |
commit | fe12e56166ba6da0466fb36c2bf499005f2746d7 (patch) | |
tree | 82f7e447e930112fbad4be29a3d3a412ea3b4aa6 /lib/sqlalchemy/util.py | |
parent | a716f3b12b71b3506a08a226fd51fd199c54c2a1 (diff) | |
download | sqlalchemy-fe12e56166ba6da0466fb36c2bf499005f2746d7.tar.gz |
full mapper test suite works with postgres
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r-- | lib/sqlalchemy/util.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index 07eb85846..2498316c1 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -101,15 +101,19 @@ class OrderedDict(dict): class ThreadLocal(object): """an object in which attribute access occurs only within the context of the current thread""" - def __init__(self): - object.__setattr__(self, 'tdict', {}) - def __getattribute__(self, key): + def __init__(self, raiseerror = True): + self.__dict__['_tdict'] = {} + self.__dict__['_raiseerror'] = raiseerror + def __getattr__(self, key): try: - return object.__getattribute__(self, 'tdict')["%d_%s" % (thread.get_ident(), key)] + return self._tdict["%d_%s" % (thread.get_ident(), key)] except KeyError: - raise AttributeError(key) + if self._raiseerror: + raise AttributeError(key) + else: + return None def __setattr__(self, key, value): - object.__getattribute__(self, 'tdict')["%d_%s" % (thread.get_ident(), key)] = value + self._tdict["%d_%s" % (thread.get_ident(), key)] = value class HashSet(object): """implements a Set.""" |