Allow CachedQueryMutator to be used not as a context manager.

This commit is contained in:
Neil Williams
2012-03-19 16:31:05 -07:00
parent b284dc80ae
commit afb4de999e

View File

@@ -196,14 +196,10 @@ class CachedQueryMutator(object):
self.to_prune = set()
def __enter__(self):
self.mutator.__enter__()
return self
def __exit__(self, type, value, traceback):
self.mutator.__exit__(type, value, traceback)
if self.to_prune:
CachedQuery._prune_multi(self.to_prune)
self.send()
def insert(self, query, things):
if not things:
@@ -220,6 +216,12 @@ class CachedQueryMutator(object):
query._delete(self.mutator, things)
def send(self):
self.mutator.send()
if self.to_prune:
CachedQuery._prune_multi(self.to_prune)
def filter_identity(x):
return x