Skip to content

Commit 52f54df

Browse files
authored
Merge branch '4.4' into bolt-utc-datetimes-4.4
2 parents 8d4778b + 923bc6d commit 52f54df

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

docs/source/api.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,16 +607,21 @@ The default access mode.
607607

608608
A session can be given a default access mode on construction.
609609

610-
This applies only in clustered environments and determines whether transactions carried out within that session should be routed to a `read` or `write` server by default.
610+
This applies only in clustered environments and determines whether transactions
611+
carried out within that session should be routed to a ``read`` or ``write``
612+
server by default.
611613

612-
Transactions (see :ref:`managed-transactions-ref`) within a session can override the access mode passed to that session on construction.
614+
Transactions (see :ref:`managed-transactions-ref`) within a session override the
615+
access mode passed to that session on construction.
613616

614617
.. note::
615-
The driver does not parse Cypher queries and cannot determine whether the access mode should be ``neo4j.ACCESS_WRITE`` or ``neo4j.ACCESS_READ``.
616-
Since the access mode is not passed to the server, this can allow a ``neo4j.ACCESS_WRITE`` statement to be executed for a ``neo4j.ACCESS_READ`` call on a single instance.
617-
Clustered environments are not susceptible to this loophole as cluster roles prevent it.
618-
This behaviour should not be relied upon as the loophole may be closed in a future release.
619-
618+
The driver does not parse Cypher queries and cannot determine whether the
619+
access mode should be ``neo4j.ACCESS_WRITE`` or ``neo4j.ACCESS_READ``.
620+
This setting is only meant to enable the driver to perform correct routing,
621+
*not* for enforcing access control. This means that, depending on the server
622+
version and settings, the server or cluster might allow a write-statement to
623+
be executed even when ``neo4j.ACCESS_READ`` is chosen. This behaviour should
624+
not be relied upon as it can change with the server.
620625

621626
:Type: ``neo4j.WRITE_ACCESS``, ``neo4j.READ_ACCESS``
622627
:Default: ``neo4j.WRITE_ACCESS``

docs/source/index.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ To deactivate the current active virtual environment, use:
9797
Quick Example
9898
*************
9999

100-
Creating nodes.
100+
Creating nodes and relationships.
101101

102102
.. code-block:: python
103103
@@ -106,15 +106,17 @@ Creating nodes.
106106
uri = "neo4j://localhost:7687"
107107
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
108108
109+
def create_person(tx, name):
110+
tx.run("CREATE (a:Person {name: $name})", name=name)
111+
109112
def create_friend_of(tx, name, friend):
110113
tx.run("MATCH (a:Person) WHERE a.name = $name "
111114
"CREATE (a)-[:KNOWS]->(:Person {name: $friend})",
112115
name=name, friend=friend)
113116
114117
with driver.session() as session:
118+
session.write_transaction(create_person, "Alice")
115119
session.write_transaction(create_friend_of, "Alice", "Bob")
116-
117-
with driver.session() as session:
118120
session.write_transaction(create_friend_of, "Alice", "Carl")
119121
120122
driver.close()
@@ -132,8 +134,8 @@ Finding nodes.
132134
def get_friends_of(tx, name):
133135
friends = []
134136
result = tx.run("MATCH (a:Person)-[:KNOWS]->(f) "
135-
"WHERE a.name = $name "
136-
"RETURN f.name AS friend", name=name)
137+
"WHERE a.name = $name "
138+
"RETURN f.name AS friend", name=name)
137139
for record in result:
138140
friends.append(record["friend"])
139141
return friends

neo4j/work/simple.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ def _run_transaction(self, access_mode, transaction_function, *args, **kwargs):
355355

356356
def read_transaction(self, transaction_function, *args, **kwargs):
357357
"""Execute a unit of work in a managed read transaction.
358+
359+
.. note::
360+
This does not necessarily imply access control, see the session
361+
configuration option :ref:`default-access-mode-ref`.
362+
358363
This transaction will automatically be committed unless an exception is thrown during query execution or by the user code.
359364
Note, that this function perform retries and that the supplied `transaction_function` might get invoked more than once.
360365
@@ -398,6 +403,11 @@ def get_two_tx(tx):
398403

399404
def write_transaction(self, transaction_function, *args, **kwargs):
400405
"""Execute a unit of work in a managed write transaction.
406+
407+
.. note::
408+
This does not necessarily imply access control, see the session
409+
configuration option :ref:`default-access-mode-ref`.
410+
401411
This transaction will automatically be committed unless an exception is thrown during query execution or by the user code.
402412
Note, that this function perform retries and that the supplied `transaction_function` might get invoked more than once.
403413

0 commit comments

Comments
 (0)