diff --git a/mongodb_proxy.py b/mongodb_proxy.py index e737511..b784300 100644 --- a/mongodb_proxy.py +++ b/mongodb_proxy.py @@ -83,7 +83,7 @@ def __getitem__(self, key): Otherwise just return the attribute. """ item = self.proxied_object[key] - if hasattr(item, '__call__'): + if hasattr(item, '__call__') or isinstance(item, pymongo.database.Database): return MongoProxy(item, self.wait_time) return item @@ -103,7 +103,7 @@ def __getattr__(self, key): that handles AutoReconnect exceptions. Otherwise wrap it in a MongoProxy object. """ attr = getattr(self.proxied_object, key) - if hasattr(attr, '__call__'): + if hasattr(attr, '__call__') or isinstance(attr, pymongo.database.Database): attributes_for_class = self.methods_needing_retry.get(self.proxied_object.__class__, []) if key in attributes_for_class: return autoretry_read(self.wait_time)(attr)