namlook/mongokit — pull request #116 by petersng (2013-01-14 23:03:16+00:00)
Title: Passing missing keyword arguments from connection to collection.find()

I've been using MongoKit for a while for a project and had to hack around this issue before.

_Problem_:
I noticed that the mongokit.Collection.find() is calling mongokit.Cursor(), which extends pymongo.Cursor(). In this flow, mongokit.Collection.find() is bypassing the pymongo.Collection.find() and is directly calling Cursor(). Keyword arguments (like read_preferences, slave_okay, etc) for the Cursor that are set during Connection initiation are not being passed in this flow.

I found that I had to set these keyword arguments for all my queries, when I really should be able to just set them on Connection initiation and have it just work for all my queries.

_Solution_:
Added checks for kwargs for the arguments that pymongo is looking for in mongokit.Collection.find(). These kwargs are then passed over to the mongokit.Cursor()->pymongo.Cursor(), similar to how pymongo does it. Also affects mongokit.Document.find(), since this method essentially calls mongokit.Collection.find()

Let me know if you would like clarification.