UUID wrapper to support working with UUIDs stored as legacy
BSON binary subtype 3.
.. doctest::
>>> import uuid
>>> from bson.binary import Binary, UUIDLegacy, UUID_SUBTYPE
>>> my_uuid = uuid.uuid4()
>>> coll = db.test
>>> coll.insert({'uuid': Binary(my_uuid.bytes, 3)})
ObjectId('...')
>>> coll.get_count({'uuid': my_uuid})
0
>>> coll.get_count({'uuid': UUIDLegacy(my_uuid)})
1
>>> coll.query( condition = {'uuid': UUIDLegacy(my_uuid)}).next()['uuid']
UUID('...')
>>>
>>> # Convert from subtype 3 to subtype 4
>>> doc = coll.query_one( condition = {'uuid': UUIDLegacy(my_uuid)})
>>> coll.save(doc)
ObjectId('...')
>>> coll.get_count({'uuid': UUIDLegacy(my_uuid)})
0
>>> coll.get_count({'uuid': {'$in': [UUIDLegacy(my_uuid), my_uuid]}})
1
>>> coll.query_one( condition = {'uuid': my_uuid})['uuid']
UUID('...')
Raises TypeError if `obj` is not an instance of :class:`~uuid.UUID`.
:Parameters:
- `obj`: An instance of :class:`~uuid.UUID`.