Hi,
I have opened a pull request on GitHub with a patch for performing
automatic per-socket one-time authentication in pymongo:
http://github.com/mongodb/mongo-python-driver/pull/5
I'm not sure whether GitHub or this forum is the best place for
discussing this proposed change, so I thought I'd mention it in both
places.
The pull request has a fairly detailed description, but here's a
summary to whet your appetite. The patch allows you to set per-
database authentication credentials on a pymongo.Connection, from
which point socket connections will be authenticated automatically the
first time you access one of those databases. Importantly, the
Connection class remembers which sockets in the pool have been
authenticated for which databases, and therefore only performs the
authenticate action when it's really necessary.
I'm new to the pymongo codebase and to MongoDB clients in general, so
I'm not sure if the approach I've taken is the best one? I welcome
feedback and suggested improvements.
I would like to work towards getting this feature into the pymongo
client in some way, whether it's based on my proposed patch or not,
because it would make it much easier for me to use pymongo in multi-
threaded web applications without having to preemptively authenticate
every operation.
Cheers,
James