From d8c3df88ab2d400049dbe9714b9c6188b6f975a8 Mon Sep 17 00:00:00 2001 From: Jeremy Carbaugh Date: Wed, 22 Jul 2009 14:26:39 -0400 Subject: [PATCH] add conn init parameter so user can pass in an existing MongoDB connection --- saucebrush/emitters.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/saucebrush/emitters.py b/saucebrush/emitters.py index b83a1e9..9c516f1 100644 --- a/saucebrush/emitters.py +++ b/saucebrush/emitters.py @@ -171,10 +171,11 @@ class MongoDBEmitter(Emitter): be inserted are required parameters. The host and port are optional, defaulting to 'localhost' and 27017, repectively. """ - def __init__(self, database, collection, host='localhost', port=27017, drop_collection=False): + def __init__(self, database, collection, host='localhost', port=27017, drop_collection=False, conn=None): super(MongoDBEmitter, self).__init__() - from pymongo.connection import Connection - conn = Connection(host, port) + if not conn: + from pymongo.connection import Connection + conn = Connection(host, port) db = conn[database] if drop_collection: db.drop_collection(collection)