SequoiaDB
 All Classes Functions
Public Member Functions | List of all members
bson.binary.UUIDLegacy Class Reference
Inheritance diagram for bson.binary.UUIDLegacy:
bson.binary.Binary

Public Member Functions

def __new__
 
def __getnewargs__
 
def uuid
 
def __repr__
 
- Public Member Functions inherited from bson.binary.Binary
def __new__
 
def subtype
 
def __getnewargs__
 
def __eq__
 
def __ne__
 
def __repr__
 

Detailed Description

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`.

Member Function Documentation

def bson.binary.UUIDLegacy.uuid (   self)
UUID instance wrapped by this UUIDLegacy instance.

The documentation for this class was generated from the following file: