Skip to content

Instantly share code, notes, and snippets.

@agalera
Created February 25, 2015 08:42
Show Gist options
  • Save agalera/05bd63db33f83068863d to your computer and use it in GitHub Desktop.
Save agalera/05bd63db33f83068863d to your computer and use it in GitHub Desktop.
middleware mongodb
class middleware_mongodb(object):
def __init__(self, db=None):
self.db = db
def __getattr__(self, attr):
if attr in dir(self.db):
return getattr(self.db, attr)
return middleware_mongodb(self.db.__getattr__(attr))
# rewrite methods
def insert(self, *args, **kwargs):
print "example", args, kwargs
return self.db.insert(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment