diff --git a/pymongo/collection.py b/pymongo/collection.py index e78d5f6b4..cacf5f3dd 100644 --- a/pymongo/collection.py +++ b/pymongo/collection.py @@ -1279,9 +1279,7 @@ class Collection(common.BaseObject): raw = res["indexes"] # >= MongoDB 2.8rc3 else: - cur = res["cursor"] - coll = self.__database[cur["ns"].split('.', 1)[1]] - raw = CommandCursor(coll, cur, addr) + raw = CommandCursor(self, res["cursor"], addr) else: raw = self.__database.system.indexes.find({"ns": self.__full_name}, {"ns": 0}, as_class=SON, @@ -1316,9 +1314,7 @@ class Collection(common.BaseObject): results = res["collections"] # >= MongoDB 2.8rc3 else: - cur = res["cursor"] - coll = self.__database[cur["ns"].split('.', 1)[1]] - results = CommandCursor(coll, cur, addr) + results = CommandCursor(self, res["cursor"], addr) for doc in results: result = doc break diff --git a/pymongo/command_cursor.py b/pymongo/command_cursor.py index 690940d70..6b2bc5c57 100644 --- a/pymongo/command_cursor.py +++ b/pymongo/command_cursor.py @@ -42,6 +42,11 @@ class CommandCursor(object): self.__batch_size = 0 self.__killed = False + if "ns" in cursor_info: + self.__ns = cursor_info["ns"] + else: + self.__ns = collection.full_name + def __del__(self): if self.__id and not self.__killed: self.__die() @@ -138,7 +143,7 @@ class CommandCursor(object): if self.__id: # Get More self.__send_message( - message.get_more(self.__collection.full_name, + message.get_more(self.__ns, self.__batch_size, self.__id)) else: # Cursor id is zero nothing else to return diff --git a/pymongo/database.py b/pymongo/database.py index 82c8ea090..f5c505119 100644 --- a/pymongo/database.py +++ b/pymongo/database.py @@ -457,9 +457,7 @@ class Database(common.BaseObject): results = res["collections"] # >= MongoDB 2.8rc3 else: - cur = res["cursor"] - coll = self[cur["ns"].split('.', 1)[1]] - results = CommandCursor(coll, cur, addr) + results = CommandCursor(self["$cmd"], res["cursor"], addr) names = [result["name"] for result in results] else: names = [result["name"] for result