Commit Graph

28 Commits

Author SHA1 Message Date
Prashant Mital
58851e1221
PYTHON-1619 Implement ObjectID Specification (#373)
PYTHON-1619 Implement ObjectID Specification
2018-08-29 12:24:28 -05:00
Bernie Hackett
61850357a0 PYTHON-1521 - Use FNV-1a for ObjectId machine bytes 2018-05-31 12:26:53 -07:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
A. Jesse Jiryu Davis
710227237a PYTHON-789 Clarify valid ObjectId input (3.0-dev). 2014-11-20 23:18:41 -05:00
A. Jesse Jiryu Davis
08dccbba46 Remove ancient version annotations.
Delete "versionchanged" and "versionadded" directives that predate 2.0.
2014-10-31 14:15:24 -04:00
A. Jesse Jiryu Davis
f91c3d61cb Use with-statements to acquire locks.
We can use with-statements now that we've dropped support
for Python 2.4.
2014-10-02 10:07:43 -04:00
Bernie Hackett
1accea6fc2 PYTHON-226 - Optimize ObjectId creation from BSON
This change optimizes creating an instance of ObjectId
from a 12 byte bytes instance. It gets us most of the way
to what was requested in the ticket without creating a
separate subtype just for decoding.

There are also a number of changes to clean up the module
in general and silence pylint complaints.
2014-08-28 21:07:14 -07:00
A. Jesse Jiryu Davis
504c5a9889 PYTHON-712 ObjectId.is_valid(None) should be False. 2014-06-18 17:02:07 -04:00
Bernie Hackett
bd8d4a3b10 PYTHON-673 - Use bytes and remove binary_type
The binary_type alias was added to support python
2.4 and 2.5, which we no longer support.
2014-04-23 13:25:00 -07:00
Luke Lovett
d4a94d30fd PYTHON-673 python 2/3 single-source for the bson module 2014-04-17 21:29:15 +00:00
A. Jesse Jiryu Davis
2fa1750b07 Update copyright notices and company name. 2014-01-31 09:36:46 -05:00
behackett
2483775f0b Silence C extension RuntimeWarning PYTHON-569
When encoding a document in C while running in a python sub interpreter
(e.g. mod_wsgi spawning sub interpreters) PyMongo would often have
to reload its cache of pure python types - ObjectId, Timestamp,
UUID, etc. - raising RuntimeWarning in the process. The reason this was
necessary is described in the mod_wsgi documentation here:

https://code.google.com/p/modwsgi/wiki/ApplicationIssues#Multiple_Python_Sub_Interpreters

With workarounds documented here:

http://api.mongodb.org/python/2.6.2/faq.html#does-pymongo-work-with-mod-wsgi

With this commit PyMongo will no longer use cached pure python types
when running in a sub interpreter. Instead it will look up pure python
types as needed (primarily when decoding BSON). This eliminates the
problem described in the mod_wsgi docs and eliminates the need for the
Runtime warning.
2013-09-16 17:24:37 -04:00
Bernie Hackett
c8f6d4aa03 ObjectId.__str__ should return str in 2.x.
This addresses the issue raised in pull request
155.
2013-02-09 13:13:45 -08:00
Ross Lawley
29b9de45db Added __ne__ for DBRefs PYTHON-440 2012-11-22 11:12:36 +00:00
behackett
001d72b245 Support non-ascii hostnames in ObjectId PYTHON-430 2012-11-08 12:44:21 -08:00
behackett
dfaadd53e8 Doc updates for PyMongo 2.3 2012-08-16 15:52:14 -07:00
Ross Lawley
f2ea613400 Added is_valid classmethod to ObjectId
Refs PYTHON-360
2012-07-10 16:09:01 +01:00
Glenn Maynard
4ecbd22c19 Initialize ObjectId._inc to a random value.
This is required to prevent collisions on very large clusters.  See
https://groups.google.com/forum/?fromgroups#!topic/mongodb-user/ajgO9wUxbos
for details.  Other drivers also initialize this field to a random value.
2012-06-15 10:21:34 -07:00
Bernie Hackett
f4ec4be807 Avoid encoding errors with pickle.loads PYTHON-355.
This works around issues caused by applications that
use sys.setdefaultencoding to set an interpreter-wide
encoding other than ascii or utf8. This is only an
issue in python 2.x. In python 3.0 and 3.1
setdefaultencoding is a noop. It was completely
removed in python 3.2.
2012-05-30 09:56:03 -07:00
behackett
0ee7170cc2 It's 2012... 2012-04-19 12:40:38 -07:00
Chris Tompkinson
80e59ddd15 Add __ne__ method to bson/objectid.py 2012-04-12 15:12:47 +01:00
behackett
6bd0238629 ObjectId rich comparison operators and doc updates. 2012-03-21 15:39:07 -07:00
behackett
7474f5cde8 Python 3 bson changes PYTHON-84 2012-03-20 13:56:15 -07:00
behackett
9f9b4a6666 Fix loading of OIDs pickled in 1.9.
Credit goes to Steve Lacy <slacy@slacy.com>
for developing the fix and test.
2011-04-04 20:43:23 -07:00
Richard Shea
f202c535d5 change ObjectId __getstate__ and __setstate__ to just use __id also added unit test for pickling/unpickling ObjectId 2011-04-02 11:10:26 -07:00
Richard Shea
c9c54575ff fix pickling of ObjectId by defining __getstate__() and __setstate__() because __slots__() is defined 2011-04-02 11:10:26 -07:00
behackett
7c35ca96c9 Use __slots__ in ObjectId PYTHON-225 2011-03-23 10:09:55 -07:00
Mike Dirolf
9c182809f3 Create a separate bson package PYTHON-60
Many of the pymongo modules have been moved into the bson
package. Aliases for those modules have been added to the pymongo
package, without deprecation warnings for now. Application developers
should begin to use the bson namespace, as deprecation of moved
modules will probably begin in the next release.
2010-09-14 13:52:50 -04:00