Skip to content
Snippets Groups Projects
Commit d7f33ea6 authored by davebshow's avatar davebshow
Browse files

a few fixes in docs

parent 11d008a2
No related branches found
No related tags found
No related merge requests found
......@@ -26,10 +26,6 @@ GLV and driver.
- *Asynchronous Python driver* for the `Gremlin Server`_ - now
provided by `aiogremlin`_
- :py:class:`Graph<goblin.driver.Graph>`
implementation that produces *native Python GLV traversals* - now
provided by `aiogremlin`_
Releases
========
The latest release of :py:mod:`goblin` is **2.0.0b1**.
......@@ -57,56 +53,6 @@ Install using pip::
The Basics
----------
**Driver**
Submit scripts and bindings to the `Gremlin Server`_::
>>> import asyncio
>>> from goblin import Cluster # alias for aiogremlin.Cluster
>>> loop = asyncio.get_event_loop()
>>> async def go(loop):
... cluster = await Cluster.open('ws://localhost:8182/gremlin', loop)
... client = await cluster.connect()
... resp = await client.submit(
... "g.addV('developer').property(k1, v1)",
... bindings={'k1': 'name', 'v1': 'Leif'})
... async for msg in resp:
... print(msg)
... await cluster.close()
>>> loop.run_until_complete(go(loop))
For more information on using the driver, see the `aiogremlin`_ documentation or the :doc:`Driver docs</driver>`
**Graph**
Generate and submit Gremlin traversals in native Python::
>>> from goblin import DriverRemoteConnection # alias for aiogremlin.DriverRemoteConnection
>>> from goblin import Graph # alias for aiogremlin.Graph
>>> async def go(loop):
... remote_connection = await DriverRemoteConnection.open(
... 'ws://localhost:8182/gremlin', 'g')
... g = Graph().traversal().withRemote(remote_connection)
... vertices = await g.V().toList()
... await remote_connection.close()
... return vertices
>>> results = loop.run_until_complete(go(loop))
>>> results
# [v[1], v[2], v[3], v[4], v[5], v[6]]
>>> loop.run_until_complete(go(g))
# {'properties': {'name': [{'value': 'Leif', 'id': 3}]}, 'label': 'developer', 'id': 2, 'type': 'vertex'}
For more information on using the :py:class:`Graph<aiogremlin.gremlin_python.structure.graph.Graph>`,
see the `aiogremlin`_ documentation or the :doc:`GLV docs</glv>`
**OGM**
Define custom vertex/edge classes using the provided base :py:mod:`classes<goblin.element>`,
......@@ -148,7 +94,7 @@ database::
... works_with = Knows(leif, jon)
... session.add(leif, jon, works_with)
... await session.flush()
... result = await session.g.E(works_with.id).oneOrNone()
... result = await session.g.E(works_with.id).next()
... assert result is works_with
... people = session.traversal(Person) # element class based traversal source
... async for person in people:
......@@ -165,6 +111,57 @@ for an element, that element will be updated to reflect these changes.
For more information on using the OGM, see the :doc:`OGM docs</ogm>`
**Gremlin Language Variant**
Generate and submit Gremlin traversals in native Python::
>>> from goblin import DriverRemoteConnection # alias for aiogremlin.DriverRemoteConnection
>>> from goblin import Graph # alias for aiogremlin.Graph
>>> async def go(loop):
... remote_connection = await DriverRemoteConnection.open(
... 'ws://localhost:8182/gremlin', 'g')
... g = Graph().traversal().withRemote(remote_connection)
... vertices = await g.V().toList()
... await remote_connection.close()
... return vertices
>>> results = loop.run_until_complete(go(loop))
>>> results
# [v[1], v[2], v[3], v[4], v[5], v[6]]
>>> loop.run_until_complete(go(g))
# {'properties': {'name': [{'value': 'Leif', 'id': 3}]}, 'label': 'developer', 'id': 2, 'type': 'vertex'}
For more information on using the :py:class:`Graph<aiogremlin.gremlin_python.structure.graph.Graph>`,
see the `aiogremlin`_ documentation or the :doc:`GLV docs</glv>`
**Driver**
Submit scripts and bindings to the `Gremlin Server`_::
>>> import asyncio
>>> from goblin import Cluster # alias for aiogremlin.Cluster
>>> loop = asyncio.get_event_loop()
>>> async def go(loop):
... cluster = await Cluster.open('ws://localhost:8182/gremlin', loop)
... client = await cluster.connect()
... resp = await client.submit(
... "g.addV('developer').property(k1, v1)",
... bindings={'k1': 'name', 'v1': 'Leif'})
... async for msg in resp:
... print(msg)
... await cluster.close()
>>> loop.run_until_complete(go(loop))
For more information on using the driver, see the `aiogremlin`_ documentation or the :doc:`Driver docs</driver>`
Contents:
......
......@@ -333,12 +333,12 @@ them as such will cause a traversal to be sent on the wire:
Furthermore, :py:mod:`Goblin` provides several convenience methods that
submit a traversal as well as process the results :py:meth:`toList`,
:py:meth:`toSet` and :py:meth:`oneOrNone`. These methods both submit a script
:py:meth:`toSet` and :py:meth:`next`. These methods both submit a script
to the server and iterate over the results. Remember to `await` the traversal
when calling these methods::
>>> traversal = session.traversal(Person)
>>> leif = await traversal.has(
... bindprop(Person, 'name', 'Leifur', binding='v1')).oneOrNone()
... bindprop(Person, 'name', 'Leifur', binding='v1')).next()
And that is pretty much it. We hope you enjoy the :py:mod:`Goblin` OGM.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment