Skip to content

Commit 2752a17

Browse files
committed
New files
1 parent c538404 commit 2752a17

File tree

6 files changed

+149
-83
lines changed

6 files changed

+149
-83
lines changed

docs/source/driver.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
**************
2+
Driver Objects
3+
**************
4+
5+
A `Driver` object holds the detail of a Neo4j database including server URIs, credentials and other configuration.
6+
It also manages a pool of connections which are used to power :class:`.Session` instances.
7+
8+
The scheme of the URI passed to the `Driver` constructor determines the type of `Driver` object constructed.
9+
Two types are currently available: the :class:`.DirectDriver` and the :class:`.RoutingDriver`.
10+
These are described in more detail below.
11+
12+
13+
.. autoclass:: neo4j.v1.GraphDatabase
14+
:members:
15+
16+
.. autoclass:: neo4j.v1.DirectDriver
17+
:members:
18+
:inherited-members:
19+
20+
.. autoclass:: neo4j.v1.RoutingDriver
21+
:members:
22+
:inherited-members:
23+
24+
.. autoclass:: neo4j.v1.AuthToken
25+
:members:
26+
27+
.. autofunction:: neo4j.v1.basic_auth
28+
29+
.. autofunction:: neo4j.v1.custom_auth
30+
31+
32+
Encryption Settings
33+
-------------------
34+
.. py:attribute:: neo4j.v1.ENCRYPTION_OFF
35+
.. py:attribute:: neo4j.v1.ENCRYPTION_ON
36+
.. py:attribute:: neo4j.v1.ENCRYPTION_DEFAULT
37+
38+
39+
Trust Settings
40+
--------------
41+
.. py:attribute:: neo4j.v1.TRUST_ON_FIRST_USE
42+
.. py:attribute:: neo4j.v1.TRUST_SIGNED_CERTIFICATES
43+
.. py:attribute:: neo4j.v1.TRUST_ALL_CERTIFICATES
44+
.. py:attribute:: neo4j.v1.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES
45+
.. py:attribute:: neo4j.v1.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES
46+
.. py:attribute:: neo4j.v1.TRUST_DEFAULT

docs/source/index.rst

Lines changed: 13 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,6 @@
1-
============================
1+
****************************
22
Neo4j Bolt Driver for Python
3-
============================
4-
5-
.. toctree::
6-
:maxdepth: 2
7-
8-
9-
Session API
10-
===========
11-
12-
.. autoclass:: neo4j.v1.GraphDatabase
13-
:members:
14-
15-
.. autoclass:: neo4j.v1.Driver
16-
:members:
17-
18-
.. autoclass:: neo4j.v1.Session
19-
:members:
20-
21-
.. autoclass:: neo4j.v1.Transaction
22-
:members:
23-
24-
.. autoclass:: neo4j.v1.Record
25-
:members:
26-
27-
.. autoclass:: neo4j.v1.StatementResult
28-
:members:
29-
30-
31-
Encryption Settings
32-
-------------------
33-
.. py:attribute:: neo4j.v1.ENCRYPTION_OFF
34-
.. py:attribute:: neo4j.v1.ENCRYPTION_ON
35-
.. py:attribute:: neo4j.v1.ENCRYPTION_NON_LOCAL
36-
.. py:attribute:: neo4j.v1.ENCRYPTION_DEFAULT
37-
38-
39-
Trust Settings
40-
--------------
41-
.. py:attribute:: neo4j.v1.TRUST_ON_FIRST_USE
42-
.. py:attribute:: neo4j.v1.TRUST_SIGNED_CERTIFICATES
43-
.. py:attribute:: neo4j.v1.TRUST_DEFAULT
44-
45-
46-
Query Summary Details
47-
---------------------
48-
49-
.. autoclass:: neo4j.v1.summary.ResultSummary
50-
:members:
51-
52-
.. autoclass:: neo4j.v1.summary.SummaryCounters
53-
:members:
54-
55-
56-
Exceptions
57-
==========
58-
59-
.. autoclass:: neo4j.v1.ProtocolError
60-
:members:
61-
62-
.. autoclass:: neo4j.v1.CypherError
63-
:members:
64-
65-
.. autoclass:: neo4j.v1.ResultError
66-
:members:
67-
68-
69-
Example
70-
=======
3+
****************************
714

725
.. code-block:: python
736
@@ -92,6 +25,17 @@ Example
9225
driver.close()
9326
9427
28+
Contents
29+
========
30+
31+
.. toctree::
32+
:maxdepth: 1
33+
34+
driver
35+
session
36+
types
37+
38+
9539
Indices and tables
9640
==================
9741

docs/source/session.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
***************
2+
Cypher Sessions
3+
***************
4+
5+
6+
.. autoclass:: neo4j.v1.Session
7+
:members:
8+
9+
.. autoclass:: neo4j.v1.Transaction
10+
:members:
11+
12+
.. autoclass:: neo4j.v1.StatementResult
13+
:members:
14+
15+
.. autoclass:: neo4j.v1.Record
16+
:members:
17+
18+
19+
Summary Details
20+
---------------
21+
22+
.. autoclass:: neo4j.v1.summary.ResultSummary
23+
:members:
24+
25+
.. autoclass:: neo4j.v1.summary.SummaryCounters
26+
:members:
27+
28+
29+
Exceptions
30+
----------
31+
32+
.. autoclass:: neo4j.v1.ProtocolError
33+
:members:
34+
35+
.. autoclass:: neo4j.v1.Unauthorized
36+
:members:
37+
38+
.. autoclass:: neo4j.v1.CypherError
39+
:members:
40+
41+
.. autoclass:: neo4j.v1.TransactionError
42+
:members:
43+
44+
.. autoclass:: neo4j.v1.ResultError
45+
:members:
46+
47+
.. autoclass:: neo4j.v1.ServiceUnavailable
48+
:members:
49+
50+
.. autoclass:: neo4j.v1.SessionExpired
51+
:members:

docs/source/types.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
***********
2+
Type System
3+
***********
4+
5+
6+
.. autoclass:: neo4j.v1.Node
7+
:members:
8+
:inherited-members:
9+
10+
.. autoclass:: neo4j.v1.Relationship
11+
:members:
12+
:inherited-members:
13+
14+
.. autoclass:: neo4j.v1.Path
15+
:members:
16+
:inherited-members:

neo4j/v1/types.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,33 @@ def __hash__(self):
5353
def __len__(self):
5454
return len(self.properties)
5555

56-
def __getitem__(self, key):
57-
return self.properties.get(key)
56+
def __getitem__(self, name):
57+
return self.properties.get(name)
5858

59-
def __contains__(self, key):
60-
return key in self.properties
59+
def __contains__(self, name):
60+
return name in self.properties
6161

6262
def __iter__(self):
6363
return iter(self.properties)
6464

65-
def get(self, key, default=None):
66-
return self.properties.get(key, default)
65+
def get(self, name, default=None):
66+
""" Get a property value by name, optionally with a default.
67+
"""
68+
return self.properties.get(name, default)
6769

6870
def keys(self):
71+
""" Return an iterable of all property names.
72+
"""
6973
return self.properties.keys()
7074

7175
def values(self):
76+
""" Return an iterable of all property values.
77+
"""
7278
return self.properties.values()
7379

7480
def items(self):
81+
""" Return an iterable of all property name-value pairs.
82+
"""
7583
return self.properties.items()
7684

7785

@@ -108,7 +116,11 @@ def __init__(self, type, properties=None, **kwproperties):
108116
class Relationship(BaseRelationship):
109117
""" Self-contained graph relationship.
110118
"""
119+
120+
#: The start node of this relationship
111121
start = None
122+
123+
#: The end node of this relationship
112124
end = None
113125

114126
@classmethod
@@ -128,11 +140,6 @@ def __repr__(self):
128140
return "<Relationship id=%r start=%r end=%r type=%r properties=%r>" % \
129141
(self.id, self.start, self.end, self.type, self.properties)
130142

131-
def unbind(self):
132-
inst = UnboundRelationship(self.type, self.properties)
133-
inst.id = self.id
134-
return inst
135-
136143

137144
class UnboundRelationship(BaseRelationship):
138145
""" Self-contained graph relationship without endpoints.

test/test_types.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ def test_can_hydrate_path(self):
127127
carol = Node.hydrate(3, {"Person"}, {"name": "Carol", "age": 55})
128128
alice_knows_bob = Relationship(alice.id, bob.id, "KNOWS", {"since": 1999})
129129
carol_dislikes_bob = Relationship(carol.id, bob.id, "DISLIKES")
130-
path = Path.hydrate([alice, bob, carol],
131-
[alice_knows_bob.unbind(), carol_dislikes_bob.unbind()],
132-
[1, 1, -2, 2])
130+
rels = [UnboundRelationship(alice_knows_bob.type, alice_knows_bob.properties),
131+
UnboundRelationship(carol_dislikes_bob.type, carol_dislikes_bob.properties)]
132+
rels[0].id = alice_knows_bob.id
133+
rels[1].id = carol_dislikes_bob.id
134+
path = Path.hydrate([alice, bob, carol], rels, [1, 1, -2, 2])
133135
assert path.start == alice
134136
assert path.end == carol
135137
assert path.nodes == (alice, bob, carol)

0 commit comments

Comments
 (0)