Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from ferrix/client

Add a constructor to override database setting
  • Loading branch information...
commit 303b0696cd91c7eabadc7ffd57dd5ddeeb09dde4 2 parents 03a8f97 + 5f0dd2d
Fatih Erikli authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 tastypie_mongodb/resources.py
6 tastypie_mongodb/resources.py
View
@@ -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.")
Please sign in to comment.
Something went wrong with that request. Please try again.