Skip to content

Commit db14819

Browse files
committed
Merge branch 'master' into fork
2 parents 24bb918 + 8fdde3a commit db14819

21 files changed

+126
-67
lines changed

bson/binary.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@
6868
"""
6969

7070
JAVA_LEGACY = 5
71-
"""Specify that UUIDs should be stored in the legacy
72-
byte order used by the Java driver.
71+
"""Used with :attr:`pymongo.collection.Collection.uuid_subtype`
72+
to specify that UUIDs should be stored in the legacy byte order
73+
used by the Java driver.
7374
7475
:class:`uuid.UUID` instances will automatically be encoded
7576
by :mod:`bson` using :data:`OLD_UUID_SUBTYPE`.
@@ -78,8 +79,9 @@
7879
"""
7980

8081
CSHARP_LEGACY = 6
81-
"""Specify that UUIDs should be stored in the legacy
82-
byte order used by the C# driver.
82+
"""Used with :attr:`pymongo.collection.Collection.uuid_subtype`
83+
to specify that UUIDs should be stored in the legacy byte order
84+
used by the C# driver.
8385
8486
:class:`uuid.UUID` instances will automatically be encoded
8587
by :mod:`bson` using :data:`OLD_UUID_SUBTYPE`.

bson/objectid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def is_valid(cls, oid):
130130
:Parameters:
131131
- `oid`: the object id to validate
132132
133-
.. versionadded:: 2.2.1+
133+
.. versionadded:: 2.3
134134
"""
135135
try:
136136
ObjectId(oid)

doc/api/bson/binary.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
.. autodata:: BINARY_SUBTYPE
88
.. autodata:: FUNCTION_SUBTYPE
99
.. autodata:: OLD_BINARY_SUBTYPE
10-
.. autodata:: UUID_SUBTYPE
1110
.. autodata:: OLD_UUID_SUBTYPE
11+
.. autodata:: UUID_SUBTYPE
12+
.. autodata:: JAVA_LEGACY
13+
.. autodata:: CSHARP_LEGACY
1214
.. autodata:: MD5_SUBTYPE
1315
.. autodata:: USER_DEFINED_SUBTYPE
1416

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Important New Features:
1616
- A new :meth:`~pymongo.collection.Collection.aggregate` method to support
1717
MongoDB's new `aggregation framework
1818
<http://docs.mongodb.org/manual/applications/aggregation/>`_.
19+
- Support for legacy Java and C# byte order when encoding and decoding UUIDs.
1920
- Support for connecting directly to an arbiter.
2021

2122
.. warning::

pymongo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
ALL = 2
4949
"""Profile all operations."""
5050

51-
version_tuple = (2, 2, 1, '+')
51+
version_tuple = (2, 3, 'rc1+')
5252

5353
def get_version_string():
5454
if isinstance(version_tuple[-1], basestring):

pymongo/collection.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ def __set_uuid_subtype(self, subtype):
189189
self.__uuid_subtype = subtype
190190

191191
uuid_subtype = property(__get_uuid_subtype, __set_uuid_subtype,
192-
doc="""This setting specifies which BSON Binary
192+
doc="""This attribute specifies which BSON Binary
193193
subtype is used when storing UUIDs. Historically
194194
UUIDs have been stored as BSON Binary subtype 3.
195-
This setting is used to switch to the newer BSON
196-
binary subtype 4. This setting can also be used to
197-
force legacy byte order and subtype compatibility
198-
with the Java and C# drivers. See the bson.binary
199-
module for all options.""")
195+
This attribute is used to switch to the newer BSON
196+
binary subtype 4. It can also be used to force
197+
legacy byte order and subtype compatibility with
198+
the Java and C# drivers. See the
199+
:mod:`bson.binary` module for all options.""")
200200

201201
def __get_context(self):
202202
return self.__context
@@ -659,7 +659,7 @@ def count(self):
659659
"""
660660
return self.find().count()
661661

662-
def create_index(self, key_or_list, ttl=300, **kwargs):
662+
def create_index(self, key_or_list, cache_for=300, **kwargs):
663663
"""Creates an index on this collection.
664664
665665
Takes either a single key or a list of (key, direction) pairs.
@@ -696,13 +696,18 @@ def create_index(self, key_or_list, ttl=300, **kwargs):
696696
:Parameters:
697697
- `key_or_list`: a single key or a list of (key, direction)
698698
pairs specifying the index to create
699-
- `ttl` (optional): time window (in seconds) during which
699+
- `cache_for` (optional): time window (in seconds) during which
700700
this index will be recognized by subsequent calls to
701701
:meth:`ensure_index` - see documentation for
702702
:meth:`ensure_index` for details
703703
- `**kwargs` (optional): any additional index creation
704704
options (see the above list) should be passed as keyword
705705
arguments
706+
- `ttl` (deprecated): Use `cache_for` instead.
707+
708+
.. versionchanged:: 2.3
709+
The `ttl` parameter has been deprecated to avoid confusion with
710+
TTL collections. Use `cache_for` instead.
706711
707712
.. versionchanged:: 2.2
708713
Removed deprecated argument: deprecated_unique
@@ -717,6 +722,12 @@ def create_index(self, key_or_list, ttl=300, **kwargs):
717722
718723
.. mongodoc:: indexes
719724
"""
725+
726+
if 'ttl' in kwargs:
727+
cache_for = kwargs.pop('ttl')
728+
warnings.warn("ttl is deprecated. Please use cache_for instead.",
729+
DeprecationWarning)
730+
720731
keys = helpers._index_list(key_or_list)
721732
index_doc = helpers._index_document(keys)
722733

@@ -738,11 +749,11 @@ def create_index(self, key_or_list, ttl=300, **kwargs):
738749
safe=True)
739750

740751
self.__database.connection._cache_index(self.__database.name,
741-
self.__name, name, ttl)
752+
self.__name, name, cache_for)
742753

743754
return name
744755

745-
def ensure_index(self, key_or_list, ttl=300, **kwargs):
756+
def ensure_index(self, key_or_list, cache_for=300, **kwargs):
746757
"""Ensures that an index exists on this collection.
747758
748759
Takes either a single key or a list of (key, direction) pairs.
@@ -788,12 +799,17 @@ def ensure_index(self, key_or_list, ttl=300, **kwargs):
788799
:Parameters:
789800
- `key_or_list`: a single key or a list of (key, direction)
790801
pairs specifying the index to create
791-
- `ttl` (optional): time window (in seconds) during which
802+
- `cache_for` (optional): time window (in seconds) during which
792803
this index will be recognized by subsequent calls to
793804
:meth:`ensure_index`
794805
- `**kwargs` (optional): any additional index creation
795806
options (see the above list) should be passed as keyword
796807
arguments
808+
- `ttl` (deprecated): Use `cache_for` instead.
809+
810+
.. versionchanged:: 2.3
811+
The `ttl` parameter has been deprecated to avoid confusion with
812+
TTL collections. Use `cache_for` instead.
797813
798814
.. versionchanged:: 2.2
799815
Removed deprecated argument: deprecated_unique
@@ -814,7 +830,7 @@ def ensure_index(self, key_or_list, ttl=300, **kwargs):
814830

815831
if not self.__database.connection._cached(self.__database.name,
816832
self.__name, name):
817-
return self.create_index(key_or_list, ttl, **kwargs)
833+
return self.create_index(key_or_list, cache_for, **kwargs)
818834
return None
819835

820836
def drop_indexes(self):

pymongo/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ def _cached(self, dbname, coll, index):
320320
index in cache[dbname][coll] and
321321
now < cache[dbname][coll][index])
322322

323-
def _cache_index(self, database, collection, index, ttl):
323+
def _cache_index(self, database, collection, index, cache_for):
324324
"""Add an index to the index cache for ensure_index operations.
325325
"""
326326
now = datetime.datetime.utcnow()
327-
expire = datetime.timedelta(seconds=ttl) + now
327+
expire = datetime.timedelta(seconds=cache_for) + now
328328

329329
if database not in self.__index_cache:
330330
self.__index_cache[database] = {}

pymongo/master_slave_connection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,10 @@ def _cached(self, database_name, collection_name, index_name):
281281
return self.__master._cached(database_name,
282282
collection_name, index_name)
283283

284-
def _cache_index(self, database_name, collection_name, index_name, ttl):
284+
def _cache_index(self, database_name, collection_name,
285+
index_name, cache_for):
285286
return self.__master._cache_index(database_name, collection_name,
286-
index_name, ttl)
287+
index_name, cache_for)
287288

288289
def _purge_index(self, database_name,
289290
collection_name=None, index_name=None):

pymongo/replica_set_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ def _cached(self, dbname, coll, index):
454454
index in cache[dbname][coll] and
455455
now < cache[dbname][coll][index])
456456

457-
def _cache_index(self, dbase, collection, index, ttl):
457+
def _cache_index(self, dbase, collection, index, cache_for):
458458
"""Add an index to the index cache for ensure_index operations.
459459
"""
460460
now = datetime.datetime.utcnow()
461-
expire = datetime.timedelta(seconds=ttl) + now
461+
expire = datetime.timedelta(seconds=cache_for) + now
462462

463463
if dbase not in self.__index_cache:
464464
self.__index_cache[dbase] = {}
@@ -815,7 +815,7 @@ def __check_is_primary(self, host):
815815
if member:
816816
member.pool.discard_socket(sock_info)
817817
raise ConnectionFailure("%s:%d: %s" % (host[0], host[1], str(why)))
818-
818+
819819
if member and sock_info:
820820
member.pool.maybe_return_socket(sock_info)
821821

setup.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from distutils.errors import DistutilsPlatformError, DistutilsExecError
3232
from distutils.core import Extension
3333

34-
version = "2.2.1+"
34+
version = "2.3rc1+"
3535

3636
f = open("README.rst")
3737
try:
@@ -129,6 +129,13 @@ class custom_build_ext(build_ext):
129129
WARNING: %s could not
130130
be compiled. No C extensions are essential for PyMongo to run,
131131
although they do result in significant speed improvements.
132+
%s
133+
134+
Please see the installation docs for solutions to build issues:
135+
136+
http://api.mongodb.org/python/current/installation.html
137+
138+
Here are some hints for popular operating systems:
132139
133140
If you are seeing this message on Linux you probably need to
134141
install GCC and/or the Python development package for your
@@ -142,7 +149,16 @@ class custom_build_ext(build_ext):
142149
143150
$ sudo yum install gcc python-devel
144151
145-
%s
152+
If you are seeing this message on Microsoft Windows please install
153+
PyMongo using the MS Windows installer for your version of Python,
154+
available on pypi here:
155+
156+
http://pypi.python.org/pypi/pymongo/#downloads
157+
158+
If you are seeing this message on OSX please read the documentation
159+
here:
160+
161+
http://api.mongodb.org/python/current/installation.html#osx
146162
********************************************************************
147163
"""
148164

@@ -180,9 +196,10 @@ def build_extension(self, ext):
180196
sys.stdout.write('%s\n' % str(e))
181197
warnings.warn(self.warning_message % ("The %s extension "
182198
"module" % (name,),
183-
"Above is the ouput "
184-
"showing how the "
185-
"compilation failed."))
199+
"The output above "
200+
"this warning shows how "
201+
"the compilation "
202+
"failed."))
186203
else:
187204
warnings.warn(self.warning_message % ("The %s extension "
188205
"module" % (name,),

0 commit comments

Comments
 (0)