Skip to content

Commit 19d6cf4

Browse files
author
Mike Dirolf
committed
complete deprecation of some things, and turn on a test that was waiting on SM being default
1 parent cb5d106 commit 19d6cf4

File tree

3 files changed

+4
-54
lines changed

3 files changed

+4
-54
lines changed

pymongo/cursor.py

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -146,37 +146,6 @@ def __check_okay_to_chain(self):
146146
if self.__retrieved or self.__id is not None:
147147
raise InvalidOperation("cannot set options after executing query")
148148

149-
# TODO complete deprecation by removing this method
150-
def slave_okay(self, slave_okay=True):
151-
"""(DEPRECATED) Specify whether this query should be allowed to execute on a slave.
152-
153-
This method is deprecated and will be removed. Use the slave_okay
154-
parameter to `pymongo.collection.Collection.find` instead.
155-
156-
By default, certain queries are not allowed to execute on mongod
157-
instances running in slave mode. If `slave_okay` is True then this
158-
query will be allowed to execute on slave instances. If False, the
159-
default behavior applies.
160-
161-
Settings made through calls to this method take precedence over any
162-
settings made elsewhere (like the slave_okay option when creating a
163-
Connection). The last `slave_okay` applied to this cursor
164-
takes precedence.
165-
166-
Raises InvalidOperation if this cursor has already been used.
167-
168-
:Parameters:
169-
- `slave_okay` (optional): should this query be allowed to execute on
170-
slave instances
171-
"""
172-
warnings.warn("the slave_okay method is deprecated and will"
173-
" be removed - use the slave_okay paramater to find()"
174-
" instead", DeprecationWarning)
175-
self.__check_okay_to_chain()
176-
177-
self.__slave_okay = slave_okay
178-
return self
179-
180149
def limit(self, limit):
181150
"""Limits the number of results to be returned by this cursor.
182151
@@ -259,17 +228,6 @@ def explain(self):
259228
c.__limit = -abs(c.__limit)
260229
return c.next()
261230

262-
def __index_name_to_list(self, index_name):
263-
"""Convert an index specified by name to an index spec list.
264-
"""
265-
# NOTE this is broken for indexes on key names containing '_'
266-
index_list = []
267-
tokens = index_name.split("_")
268-
for key, direction in zip(tokens[::2], tokens[1::2]):
269-
index_list.append((key, int(direction)))
270-
return index_list
271-
272-
# TODO at some point fully deprecate index name - it could be buggy
273231
def hint(self, index):
274232
"""Adds a 'hint', telling Mongo the proper index to use for the query.
275233
@@ -292,14 +250,8 @@ def hint(self, index):
292250
self.__hint = None
293251
return self
294252

295-
if not isinstance(index, (types.StringTypes, types.ListType)):
296-
raise TypeError("hint takes an index name or "
297-
"a list specifying an index")
298-
if isinstance(index, types.StringTypes):
299-
warnings.warn("hinting using an index name is deprecated and will"
300-
" be removed - use a regular index spec instead",
301-
DeprecationWarning)
302-
index = self.__index_name_to_list(index)
253+
if not isinstance(index, (types.ListType)):
254+
raise TypeError("hint takes a list specifying an index")
303255
self.__hint = pymongo._index_document(index)
304256
return self
305257

test/test_cursor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def test_hint(self):
7979
break
8080
self.assertRaises(InvalidOperation, a.hint, spec)
8181

82-
warnings.simplefilter("error")
83-
self.assertRaises(DeprecationWarning, db.test.find().hint, index)
82+
self.assertRaises(TypeError, db.test.find().hint, index)
8483

8584
# TODO right now this doesn't actually test anything useful, just that the
8685
# call doesn't blow up in the normal case.

test/test_database.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ def test_eval(self):
297297
self.assertEqual(5, db.eval("2 + 3;"))
298298

299299
self.assertEqual(5, db.eval(Code("2 + 3;")))
300-
# TODO turn this back on when SM is the default
301-
#self.assertRaises( OperationFailure , db.eval , (Code("return i;")) )
300+
self.assertRaises(OperationFailure, db.eval, Code("return i;"))
302301
self.assertEqual(2, db.eval(Code("return i;", {"i": 2})))
303302
self.assertEqual(5, db.eval(Code("i + 3;", {"i": 2})))
304303

0 commit comments

Comments
 (0)