Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Goblin
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goblin OGM
Goblin
Commits
d7f33ea6
Commit
d7f33ea6
authored
8 years ago
by
davebshow
Browse files
Options
Downloads
Patches
Plain Diff
a few fixes in docs
parent
11d008a2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/index.rst
+52
-55
52 additions, 55 deletions
docs/index.rst
docs/ogm.rst
+2
-2
2 additions, 2 deletions
docs/ogm.rst
with
54 additions
and
57 deletions
docs/index.rst
+
52
−
55
View file @
d7f33ea6
...
...
@@ -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).
o
ne
OrNone
()
... result = await session.g.E(works_with.id).ne
xt
()
... 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:
...
...
This diff is collapsed.
Click to expand it.
docs/ogm.rst
+
2
−
2
View file @
d7f33ea6
...
...
@@ -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:`
o
ne
OrNone
`. These methods both submit a script
:py:meth:`toSet` and :py:meth:`ne
xt
`. 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')).
o
ne
OrNone
()
... bindprop(Person, 'name', 'Leifur', binding='v1')).ne
xt
()
And that is pretty much it. We hope you enjoy the :py:mod:`Goblin` OGM.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment