Permalink
Browse files

Merge pull request #3 from ferrix/client

Add a constructor to override database setting
  • Loading branch information...
2 parents 03a8f97 + 5f0dd2d commit 303b0696cd91c7eabadc7ffd57dd5ddeeb09dde4 @fatiherikli committed Oct 3, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 tastypie_mongodb/resources.py
@@ -32,12 +32,16 @@ class MongoDBResource(Resource):
"""
A base resource that allows to make CRUD operations for mongodb.
"""
+ def __init__(self, database=None):
+ if not database:
+ self.database = db
+
def get_collection(self):
"""
Encapsulates collection name.
"""
try:
- return db[self._meta.collection]
+ return self.database[self._meta.collection]
except AttributeError:
raise ImproperlyConfigured("Define a collection in your resource.")

0 comments on commit 303b069

Please sign in to comment.