Skip to content

Commit 4075ed5

Browse files
committed
Make neo4j.conf and neo4j.routing internal
1 parent e06e920 commit 4075ed5

31 files changed

+136
-163
lines changed

neo4j/__conf.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

neo4j/__init__.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@
7171

7272
from logging import getLogger
7373

74-
from .__conf import (
75-
TrustAll,
76-
TrustCustomCAs,
77-
TrustSystemCAs,
78-
)
7974
from ._async.driver import (
8075
AsyncBoltDriver,
8176
AsyncDriver,
@@ -88,6 +83,15 @@
8883
AsyncSession,
8984
AsyncTransaction,
9085
)
86+
from ._conf import (
87+
Config,
88+
PoolConfig,
89+
SessionConfig,
90+
TrustAll,
91+
TrustCustomCAs,
92+
TrustSystemCAs,
93+
WorkspaceConfig,
94+
)
9195
from ._data import Record
9296
from ._meta import (
9397
ExperimentalWarning,
@@ -131,12 +135,6 @@
131135
Version,
132136
WRITE_ACCESS,
133137
)
134-
from .conf import (
135-
Config,
136-
PoolConfig,
137-
SessionConfig,
138-
WorkspaceConfig,
139-
)
140138
from .work import (
141139
Query,
142140
ResultSummary,

neo4j/_async/driver.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
# limitations under the License.
1717

1818

19-
from ..__conf import (
19+
from .._async_compat.util import AsyncUtil
20+
from .._conf import (
21+
Config,
22+
PoolConfig,
23+
SessionConfig,
2024
TrustAll,
2125
TrustStore,
26+
WorkspaceConfig,
2227
)
23-
from .._async_compat.util import AsyncUtil
2428
from .._meta import (
2529
deprecation_warn,
2630
experimental,
@@ -32,12 +36,6 @@
3236
TRUST_ALL_CERTIFICATES,
3337
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
3438
)
35-
from ..conf import (
36-
Config,
37-
PoolConfig,
38-
SessionConfig,
39-
WorkspaceConfig,
40-
)
4139

4240

4341
class AsyncGraphDatabase:

neo4j/_async/io/_bolt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from ..._async_compat.util import AsyncUtil
2727
from ..._codec.hydration import v1 as hydration_v1
2828
from ..._codec.packstream import v1 as packstream_v1
29+
from ..._conf import PoolConfig
2930
from ..._exceptions import (
3031
BoltError,
3132
BoltHandshakeError,
@@ -37,7 +38,6 @@
3738
ServerInfo,
3839
Version,
3940
)
40-
from ...conf import PoolConfig
4141
from ...exceptions import (
4242
AuthError,
4343
DriverError,

neo4j/_async/io/_pool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,22 @@
3131
AsyncRLock,
3232
)
3333
from ..._async_compat.network import AsyncNetworkUtil
34+
from ..._conf import (
35+
PoolConfig,
36+
WorkspaceConfig,
37+
)
3438
from ..._deadline import (
3539
connection_deadline,
3640
Deadline,
3741
merge_deadlines,
3842
merge_deadlines_and_timeouts,
3943
)
4044
from ..._exceptions import BoltError
45+
from ..._routing import RoutingTable
4146
from ...api import (
4247
READ_ACCESS,
4348
WRITE_ACCESS,
4449
)
45-
from ...conf import (
46-
PoolConfig,
47-
WorkspaceConfig,
48-
)
4950
from ...exceptions import (
5051
ClientError,
5152
ConfigurationError,
@@ -56,7 +57,6 @@
5657
SessionExpired,
5758
WriteServiceUnavailable,
5859
)
59-
from ...routing import RoutingTable
6060
from ._bolt import AsyncBolt
6161

6262

neo4j/_async/work/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from time import perf_counter
2222

2323
from ..._async_compat import async_sleep
24+
from ..._conf import SessionConfig
2425
from ..._meta import (
2526
deprecated,
2627
deprecation_warn,
@@ -30,7 +31,6 @@
3031
READ_ACCESS,
3132
WRITE_ACCESS,
3233
)
33-
from ...conf import SessionConfig
3434
from ...exceptions import (
3535
ClientError,
3636
DriverError,

neo4j/_async/work/workspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import asyncio
2020

21+
from ..._conf import WorkspaceConfig
2122
from ..._deadline import Deadline
2223
from ..._meta import (
2324
deprecation_warn,
2425
unclosed_resource_warn,
2526
)
26-
from ...conf import WorkspaceConfig
2727
from ...exceptions import (
2828
ServiceUnavailable,
2929
SessionExpired,

neo4j/conf.py renamed to neo4j/_conf.py

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
from abc import ABCMeta
2020
from collections.abc import Mapping
2121

22-
from .__conf import (
23-
TrustAll,
24-
TrustCustomCAs,
25-
TrustSystemCAs,
26-
)
2722
from ._meta import (
2823
deprecation_warn,
2924
get_user_agent,
@@ -52,6 +47,76 @@ def iter_items(iterable):
5247
yield key, value
5348

5449

50+
class TrustStore:
51+
# Base class for trust stores. For internal type-checking only.
52+
pass
53+
54+
55+
class TrustSystemCAs(TrustStore):
56+
"""Used to configure the driver to trust system CAs (default).
57+
58+
Trust server certificates that can be verified against the system
59+
certificate authority. This option is primarily intended for use with
60+
full certificates.
61+
62+
For example::
63+
64+
import neo4j
65+
66+
driver = neo4j.GraphDatabase.driver(
67+
url, auth=auth, trusted_certificates=neo4j.TrustSystemCAs()
68+
)
69+
"""
70+
pass
71+
72+
73+
class TrustAll(TrustStore):
74+
"""Used to configure the driver to trust all certificates.
75+
76+
Trust any server certificate. This ensures that communication
77+
is encrypted but does not verify the server certificate against a
78+
certificate authority. This option is primarily intended for use with
79+
the default auto-generated server certificate.
80+
81+
82+
For example::
83+
84+
import neo4j
85+
86+
driver = neo4j.GraphDatabase.driver(
87+
url, auth=auth, trusted_certificates=neo4j.TrustAll()
88+
)
89+
"""
90+
pass
91+
92+
93+
class TrustCustomCAs(TrustStore):
94+
"""Used to configure the driver to trust custom CAs.
95+
96+
Trust server certificates that can be verified against the certificate
97+
authority at the specified paths. This option is primarily intended for
98+
self-signed and custom certificates.
99+
100+
:param certificates (str): paths to the certificates to trust.
101+
Those are not the certificates you expect to see from the server but
102+
the CA certificates you expect to be used to sign the server's
103+
certificate.
104+
105+
For example::
106+
107+
import neo4j
108+
109+
driver = neo4j.GraphDatabase.driver(
110+
url, auth=auth,
111+
trusted_certificates=neo4j.TrustCustomCAs(
112+
"/path/to/ca1.crt", "/path/to/ca2.crt",
113+
)
114+
)
115+
"""
116+
def __init__(self, *certificates):
117+
self.certs = certificates
118+
119+
55120
class DeprecatedAlias:
56121
"""Used when a config option has been renamed."""
57122

neo4j/_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from functools import reduce
2929
from operator import xor as xor_operator
3030

31-
from .conf import iter_items
31+
from ._conf import iter_items
3232
from .graph import (
3333
Node,
3434
Path,

neo4j/routing.py renamed to neo4j/_routing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def should_be_purged_from_memory(self):
146146
:return: Returns true if it is old and not used for a while.
147147
:rtype: bool
148148
"""
149-
from neo4j.conf import RoutingConfig
149+
from neo4j._conf import RoutingConfig
150150
perf_time = perf_counter()
151151
log.debug("[#0000] C: <ROUTING AGED> last_updated_time=%r perf_time=%r", self.last_updated_time, perf_time)
152152
return self.last_updated_time + self.ttl + RoutingConfig.routing_table_purge_delay <= perf_time

neo4j/_sync/driver.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
# limitations under the License.
1717

1818

19-
from ..__conf import (
19+
from .._async_compat.util import Util
20+
from .._conf import (
21+
Config,
22+
PoolConfig,
23+
SessionConfig,
2024
TrustAll,
2125
TrustStore,
26+
WorkspaceConfig,
2227
)
23-
from .._async_compat.util import Util
2428
from .._meta import (
2529
deprecation_warn,
2630
experimental,
@@ -32,12 +36,6 @@
3236
TRUST_ALL_CERTIFICATES,
3337
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
3438
)
35-
from ..conf import (
36-
Config,
37-
PoolConfig,
38-
SessionConfig,
39-
WorkspaceConfig,
40-
)
4139

4240

4341
class GraphDatabase:

neo4j/_sync/io/_bolt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from ..._async_compat.util import Util
2727
from ..._codec.hydration import v1 as hydration_v1
2828
from ..._codec.packstream import v1 as packstream_v1
29+
from ..._conf import PoolConfig
2930
from ..._exceptions import (
3031
BoltError,
3132
BoltHandshakeError,
@@ -37,7 +38,6 @@
3738
ServerInfo,
3839
Version,
3940
)
40-
from ...conf import PoolConfig
4141
from ...exceptions import (
4242
AuthError,
4343
DriverError,

0 commit comments

Comments
 (0)