-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:any
-
Minor Change
Consider the following code example:
>>> class MyManipulator(SONManipulator):
... def transform_incoming(self, son, collection):
... print "Transforming!"
... return son
>>> m = MyManipulator()
>>> db.add_son_manipulator(m)
>>> db.add_son_manipulator(m)
>>> db.add_son_manipulator(m)
>>> db.add_son_manipulator(m)
>>> db.add_son_manipulator(m)
>>> col = db.foobar
>>> col
Collection(Database(Connection('localhost', 27017), u'playhaven'), u'foobar')
>>> db.foobar.insert(
)
Transforming!
Transforming!
Transforming!
Transforming!
Transforming!
ObjectId('4c58593d860f970350000001')
It's easy to see how this could cause performance problems if extra care is not taken. What would be nice is if the method would only add the same SONManipulator once. Or at a very minimum, there should be a way to check and see if the SONManipulator has already been added.