Commit 22912847 by Michael Cetrulo

compact EXECUTABLE_MONGO_METHODS

parent f580ed27
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
import time import time
import pymongo import pymongo
def get_methods(obj): def get_methods(*objs):
attrs = (attr for attr in dir(obj)) return set(
attrs = (attr for attr in attrs if not attr.startswith('_')) attr
return set([attr for attr in attrs if hasattr(getattr(obj, attr), '__call__')]) for obj in objs
for attr in dir(obj)
EXECUTABLE_MONGO_METHODS = get_methods(pymongo.collection.Collection) if not attr.startswith('_')
EXECUTABLE_MONGO_METHODS.update(get_methods(pymongo.Connection)) and hasattr(getattr(obj, attr), '__call__')
EXECUTABLE_MONGO_METHODS.update(get_methods(pymongo)) )
EXECUTABLE_MONGO_METHODS = get_methods(pymongo.collection.Collection,
pymongo.Connection,
pymongo)
def safe_mongocall(call): def safe_mongocall(call):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment