~crunch.io/ubuntu/precise/pymongo/unstable

« back to all changes in this revision

Viewing changes to pymongo/__init__.py

  • Committer: Joseph Tate
  • Date: 2013-01-31 08:00:57 UTC
  • mfrom: (1.1.12)
  • Revision ID: jtate@dragonstrider.com-20130131080057-y7lv17xi6x8c1j5x
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
.. versionadded:: 1.5.1
27
27
 
28
 
.. note:: Geo-spatial indexing requires server version **>= 1.3.3+**.
 
28
.. note:: Geo-spatial indexing requires server version **>= 1.3.3**.
29
29
 
30
 
.. _geospatial index: http://www.mongodb.org/display/DOCS/Geospatial+Indexing
 
30
.. _geospatial index: http://docs.mongodb.org/manual/core/geospatial-indexes/
31
31
"""
32
32
 
33
33
GEOHAYSTACK = "geoHaystack"
35
35
 
36
36
.. versionadded:: 2.1
37
37
 
38
 
.. note:: Geo-spatial indexing requires server version **>= 1.5.6+**.
 
38
.. note:: Geo-spatial indexing requires server version **>= 1.5.6**.
39
39
 
40
 
.. _geospatial index: http://www.mongodb.org/display/DOCS/Geospatial+Haystack+Indexing
 
40
.. _haystack index: http://docs.mongodb.org/manual/core/geospatial-indexes/#haystack-indexes
41
41
"""
42
42
 
43
 
 
44
43
OFF = 0
45
44
"""No database profiling."""
46
45
SLOW_ONLY = 1
48
47
ALL = 2
49
48
"""Profile all operations."""
50
49
 
51
 
class ReadPreference:
52
 
    """An enum that defines the read preferences supported by PyMongo.
53
 
 
54
 
    +----------------------+--------------------------------------------------+
55
 
    |    Connection type   |                 Read Preference                  |
56
 
    +======================+================+================+================+
57
 
    |                      |`PRIMARY`       |`SECONDARY`     |`SECONDARY_ONLY`|
58
 
    +----------------------+----------------+----------------+----------------+
59
 
    |Connection to a single|Queries are     |Queries are     |Same as         |
60
 
    |host.                 |allowed if the  |allowed if the  |`SECONDARY`     |
61
 
    |                      |connection is to|connection is to|                |
62
 
    |                      |the replica set |the replica set |                |
63
 
    |                      |primary.        |primary or a    |                |
64
 
    |                      |                |secondary.      |                |
65
 
    +----------------------+----------------+----------------+----------------+
66
 
    |Connection to a       |Queries are sent|Queries are     |Same as         |
67
 
    |mongos.               |to the primary  |distributed     |`SECONDARY`     |
68
 
    |                      |of a shard.     |among shard     |                |
69
 
    |                      |                |secondaries.    |                |
70
 
    |                      |                |Queries are sent|                |
71
 
    |                      |                |to the primary  |                |
72
 
    |                      |                |if no           |                |
73
 
    |                      |                |secondaries are |                |
74
 
    |                      |                |available.      |                |
75
 
    |                      |                |                |                |
76
 
    +----------------------+----------------+----------------+----------------+
77
 
    |ReplicaSetConnection  |Queries are sent|Queries are     |Queries are     |
78
 
    |                      |to the primary  |distributed     |never sent to   |
79
 
    |                      |of the replica  |among replica   |the replica set |
80
 
    |                      |set.            |set secondaries.|primary. An     |
81
 
    |                      |                |Queries are sent|exception is    |
82
 
    |                      |                |to the primary  |raised if no    |
83
 
    |                      |                |if no           |secondary is    |
84
 
    |                      |                |secondaries are |available.      |
85
 
    |                      |                |available.      |                |
86
 
    |                      |                |                |                |
87
 
    +----------------------+----------------+----------------+----------------+
88
 
    """
89
 
 
90
 
    PRIMARY = 0
91
 
    SECONDARY = 1
92
 
    SECONDARY_ONLY = 2
93
 
 
94
 
version_tuple = (2, 2)
 
50
version_tuple = (2, 4, 2)
95
51
 
96
52
def get_version_string():
97
53
    if isinstance(version_tuple[-1], basestring):
102
58
"""Current version of PyMongo."""
103
59
 
104
60
from pymongo.connection import Connection
 
61
from pymongo.mongo_client import MongoClient
 
62
from pymongo.mongo_replica_set_client import MongoReplicaSetClient
105
63
from pymongo.replica_set_connection import ReplicaSetConnection
 
64
from pymongo.read_preferences import ReadPreference
106
65
 
107
66
def has_c():
108
67
    """Is the C extension installed?