Created
February 25, 2015 08:42
-
-
Save agalera/05bd63db33f83068863d to your computer and use it in GitHub Desktop.
middleware mongodb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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