Skip to content

Commit 923bc6d

Browse files
authored
API docs: be more explicit about access modes (#753)
1 parent 41cf203 commit 923bc6d

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
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``

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)