diff --git a/pymongo/common.py b/pymongo/common.py index 638c67fadc..b2e80313bf 100644 --- a/pymongo/common.py +++ b/pymongo/common.py @@ -60,23 +60,23 @@ def validate_basestring(option, value): "instance of basestring" % (option,)) +# jounal is an alias for j, +# wtimeoutms is an alias for wtimeout VALIDATORS = { 'replicaset': validate_basestring, 'slaveok': validate_boolean, 'safe': validate_boolean, 'w': validate_integer, 'wtimeout': validate_integer, + 'wtimeoutms': validate_integer, 'fsync': validate_boolean, 'j': validate_boolean, + 'journal': validate_boolean, 'maxpoolsize': validate_integer, } UNSUPPORTED = frozenset([ - 'connect', - 'minpoolsize', - 'waitqueuetimeoutms', - 'waitqueuemultiple', 'connecttimeoutms', 'sockettimeoutms' ]) @@ -85,8 +85,10 @@ def validate_basestring(option, value): SAFE_OPTIONS = frozenset([ 'w', 'wtimeout', + 'wtimeoutms', 'fsync', - 'j' + 'j', + 'journal' ]) @@ -124,7 +126,12 @@ def _set_options(self, **options): elif option == 'safe': self.safe = value elif option in SAFE_OPTIONS: - self.__set_safe_option(option, value) + if option == 'journal': + self.__set_safe_option('j', value) + elif option == 'wtimeoutms': + self.__set_safe_option('wtimeout', value) + else: + self.__set_safe_option(option, value) def __get_slave_okay(self): """Is it OK to perform queries on a secondary or slave? diff --git a/pymongo/connection.py b/pymongo/connection.py index 184be24516..b8e6976eb7 100644 --- a/pymongo/connection.py +++ b/pymongo/connection.py @@ -218,8 +218,8 @@ def __init__(self, host=None, port=None, max_pool_size=10, - `slave_okay` or `slaveok`: Is it OK to perform queries if this connection is to a secondary? - `safe`: Use getlasterror for each write operation? - - `j`: Block until write operations have been commited to the - journal. Ignored if the server is running without journaling. + - `j` or `journal`: Block until write operations have been commited + to the journal. Ignored if the server is running without journaling. Implies safe=True. - `w`: If this is a replica set the server won't return until write operations have replicated to this many set members. diff --git a/test/test_common.py b/test/test_common.py index 346ecfc49d..df93e8f715 100644 --- a/test/test_common.py +++ b/test/test_common.py @@ -59,6 +59,12 @@ def test_baseobject(self): cursor = coll.find(slave_okay=False) self.assertFalse(cursor._Cursor__slave_okay) + c = Connection('mongodb://localhost:27017/?' + 'w=2;wtimeoutMS=300;fsync=true;journal=true') + self.assertTrue(c.safe) + d = {'w': 2, 'wtimeout': 300, 'fsync': True, 'j': True} + self.assertEqual(d, c.get_lasterror_options()) + c = Connection('mongodb://localhost:27017/?' 'slaveok=true;w=1;wtimeout=300;fsync=true;j=true') self.assertTrue(c.slave_okay) diff --git a/test/test_uri_parser.py b/test/test_uri_parser.py index e5bb3b17dc..97bad0f64f 100644 --- a/test/test_uri_parser.py +++ b/test/test_uri_parser.py @@ -73,12 +73,6 @@ def test_split_hosts(self): def test_split_options(self): # This should remind us to write tests for these if # they are ever supported. - self.assertRaises(UnsupportedOption, split_options, - 'minPoolSize=5') - self.assertRaises(UnsupportedOption, split_options, - 'waitQueueTimeoutMS=500') - self.assertRaises(UnsupportedOption, split_options, - 'waitQueueMultiple=5') self.assertRaises(UnsupportedOption, split_options, 'connectTimeoutMS=500') self.assertRaises(UnsupportedOption, split_options,