|
28 | 28 | # Make e.g. "from pymongo.errors import AutoReconnect" work. Note that |
29 | 29 | # importing * won't pick up underscore-prefixed attrs. |
30 | 30 | from gridfs import * |
31 | | -from gridfs import _disallow_transactions |
32 | 31 | from gridfs.errors import * |
33 | | -from gridfs.grid_file import ( |
| 32 | +from gridfs.synchronous.grid_file import ( |
34 | 33 | _SEEK_CUR, |
35 | 34 | _SEEK_END, |
36 | 35 | _UPLOAD_BUFFER_CHUNKS, |
|
59 | 58 | server_type, |
60 | 59 | srv_resolver, |
61 | 60 | ssl_support, |
| 61 | + uri_parser, |
62 | 62 | write_concern, |
63 | 63 | ) |
64 | 64 |
|
|
67 | 67 | from pymongo import _csot |
68 | 68 | except ImportError: |
69 | 69 | pass |
70 | | -from pymongo import client_session |
| 70 | +from pymongo import client_session, synchronous |
71 | 71 | from pymongo.auth import * |
72 | | -from pymongo.auth import _build_credentials_tuple, _password_digest |
73 | | -from pymongo.client_session import TransactionOptions, _TxnState |
| 72 | +from pymongo.client_session import TransactionOptions |
74 | 73 | from pymongo.collation import * |
75 | 74 | from pymongo.common import * |
76 | 75 | from pymongo.common import _MAX_END_SESSIONS, _UUID_REPRESENTATIONS |
77 | 76 | from pymongo.compression_support import _have_snappy, _have_zlib, _have_zstd |
78 | 77 | from pymongo.cursor import * |
79 | | -from pymongo.cursor import _QUERY_OPTIONS |
| 78 | +from pymongo.cursor_shared import _QUERY_OPTIONS |
80 | 79 | from pymongo.encryption import * |
81 | | -from pymongo.encryption import _MONGOCRYPTD_TIMEOUT_MS, _Encrypter |
82 | 80 | from pymongo.encryption_options import * |
83 | 81 | from pymongo.encryption_options import _HAVE_PYMONGOCRYPT |
84 | 82 | from pymongo.errors import * |
85 | 83 | from pymongo.event_loggers import * |
86 | | -from pymongo.helpers import _check_command_response |
| 84 | +from pymongo.helpers_shared import _SENSITIVE_COMMANDS, _check_command_response |
87 | 85 | from pymongo.lock import _create_lock |
88 | 86 | from pymongo.message import ( |
89 | 87 | _COMMAND_OVERHEAD, |
90 | 88 | _CursorAddress, |
91 | 89 | _gen_find_command, |
92 | 90 | _maybe_add_read_preference, |
93 | 91 | ) |
94 | | -from pymongo.monitor import * |
95 | 92 | from pymongo.monitoring import * |
96 | | -from pymongo.monitoring import _LISTENERS, _SENSITIVE_COMMANDS, _Listeners |
| 93 | +from pymongo.monitoring import _LISTENERS, _Listeners |
97 | 94 | from pymongo.ocsp_cache import _OCSPCache |
98 | 95 | from pymongo.operations import * |
99 | | -from pymongo.periodic_executor import * |
100 | | -from pymongo.periodic_executor import _EXECUTORS |
101 | | -from pymongo.pool import * |
102 | | -from pymongo.pool import _METADATA, Connection, Pool, _PoolClosedError |
103 | 96 | from pymongo.read_concern import * |
104 | 97 | from pymongo.read_preferences import * |
105 | 98 | from pymongo.read_preferences import _ServerMode |
106 | 99 | from pymongo.results import * |
107 | 100 | from pymongo.results import _WriteResult |
108 | 101 | from pymongo.saslprep import * |
109 | | -from pymongo.server import * |
110 | 102 | from pymongo.server_selectors import * |
111 | | -from pymongo.settings import * |
112 | 103 | from pymongo.srv_resolver import _resolve, _SrvResolver |
113 | 104 | from pymongo.ssl_support import * |
114 | | -from pymongo.topology import * |
| 105 | +from pymongo.synchronous.client_session import _TxnState |
| 106 | +from pymongo.synchronous.monitor import * |
| 107 | +from pymongo.synchronous.periodic_executor import * |
| 108 | +from pymongo.synchronous.periodic_executor import _EXECUTORS |
| 109 | +from pymongo.synchronous.pool import * |
| 110 | +from pymongo.synchronous.pool import Connection, Pool, _PoolClosedError |
| 111 | +from pymongo.synchronous.server import * |
| 112 | +from pymongo.synchronous.settings import * |
| 113 | +from pymongo.synchronous.topology import * |
115 | 114 | from pymongo.topology_description import * |
116 | 115 | from pymongo.uri_parser import * |
117 | 116 | from pymongo.uri_parser import _have_dnspython |
|
131 | 130 |
|
132 | 131 | _MotorRawBatchCursor = create_motor_class(_AgnosticRawBatchCursor) |
133 | 132 | _MotorRawBatchCommandCursor = create_motor_class(_AgnosticRawBatchCommandCursor) |
| 133 | +get_hosts_and_min_ttl = _SrvResolver.get_hosts_and_min_ttl |
134 | 134 |
|
135 | 135 |
|
136 | 136 | def wrap_synchro(fn): |
@@ -262,9 +262,6 @@ class SynchroMeta(type): |
262 | 262 |
|
263 | 263 | - Motor methods which return Motor class instances are wrapped to return |
264 | 264 | Synchro class instances. |
265 | | -
|
266 | | - - Certain internals accessed by PyMongo's unittests, such as _Cursor__data, |
267 | | - are delegated from Synchro directly to PyMongo. |
268 | 265 | """ |
269 | 266 |
|
270 | 267 | def __new__(cls, name, bases, attrs): |
@@ -395,9 +392,10 @@ def __getitem__(self, name): |
395 | 392 | return Database(self, name, delegate=self.delegate[name]) |
396 | 393 |
|
397 | 394 | # For PyMongo tests that access client internals. |
398 | | - _MongoClient__all_credentials = SynchroProperty() |
399 | | - _MongoClient__kill_cursors_queue = SynchroProperty() |
400 | | - _MongoClient__options = SynchroProperty() |
| 395 | + _connect = Sync() |
| 396 | + _all_credentials = SynchroProperty() |
| 397 | + _kill_cursors_queue = SynchroProperty() |
| 398 | + _options = SynchroProperty() |
401 | 399 | _cache_credentials = SynchroProperty() |
402 | 400 | _close_cursor_now = SynchroProperty() |
403 | 401 | _get_topology = SynchroProperty() |
@@ -577,6 +575,16 @@ class Cursor(Synchro): |
577 | 575 | rewind = WrapOutgoing() |
578 | 576 | clone = WrapOutgoing() |
579 | 577 | close = Sync("close") |
| 578 | + to_list = Sync("to_list") |
| 579 | + |
| 580 | + _query_flags = SynchroProperty() |
| 581 | + _data = SynchroProperty() |
| 582 | + _max_time_ms = SynchroProperty() |
| 583 | + _max_await_time_ms = SynchroProperty() |
| 584 | + _retrieved = SynchroProperty() |
| 585 | + _spec = SynchroProperty() |
| 586 | + _exhaust = SynchroProperty() |
| 587 | + _query_spec = SynchroProperty() |
580 | 588 |
|
581 | 589 | _next = Sync("next") |
582 | 590 |
|
@@ -618,22 +626,12 @@ def __exit__(self, exc_type, exc_val, exc_tb): |
618 | 626 | # Don't suppress exceptions. |
619 | 627 | return False |
620 | 628 |
|
621 | | - # For PyMongo tests that access cursor internals. |
622 | | - _Cursor__data = SynchroProperty() |
623 | | - _Cursor__exhaust = SynchroProperty() |
624 | | - _Cursor__max_await_time_ms = SynchroProperty() |
625 | | - _Cursor__max_time_ms = SynchroProperty() |
626 | | - _Cursor__query_flags = SynchroProperty() |
627 | | - _Cursor__query_spec = SynchroProperty() |
628 | | - _Cursor__retrieved = SynchroProperty() |
629 | | - _Cursor__spec = SynchroProperty() |
630 | | - _read_preference = SynchroProperty() |
631 | | - |
632 | 629 |
|
633 | 630 | class CommandCursor(Cursor): |
634 | 631 | __delegate_class__ = motor.motor_tornado.MotorCommandCursor |
635 | 632 |
|
636 | 633 | try_next = Sync("try_next") |
| 634 | + to_list = Sync("to_list") |
637 | 635 |
|
638 | 636 |
|
639 | 637 | class GridOutCursor(Cursor): |
|
0 commit comments