You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/08/19 20:20:28 UTC
tinkerpop git commit: gremlin-variants.asciidoc updated
withBindings() note. Python withBindings() added though it 'does nothing' as
Bindings.of() just creates a 2-tuple. Though point is that it makes the
language perfectly consistent.
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1278 9e3d8a6b5 -> ab252fc2f
gremlin-variants.asciidoc updated withBindings() note. Python withBindings() added though it 'does nothing' as Bindings.of() just creates a 2-tuple. Though point is that it makes the language perfectly consistent.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ab252fc2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ab252fc2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ab252fc2
Branch: refs/heads/TINKERPOP-1278
Commit: ab252fc2f030708d315ab93691d12577dd0780dd
Parents: 9e3d8a6
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Aug 19 14:20:22 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Aug 19 14:20:22 2016 -0600
----------------------------------------------------------------------
docs/src/reference/gremlin-variants.asciidoc | 6 ++++--
.../gremlin/python/GraphTraversalSourceGenerator.groovy | 2 ++
.../gremlin/python/TraversalSourceGenerator.groovy | 9 ++++++++-
.../src/main/jython/gremlin_python/process/__init__.py | 1 +
.../main/jython/gremlin_python/process/graph_traversal.py | 3 +++
.../src/main/jython/gremlin_python/process/traversal.py | 9 ++++++++-
6 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ab252fc2/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index 73541d6..43f041c 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -185,8 +185,10 @@ g.V(('id',1)).out('created').name.toList()
g.V(('id',4)).out('created').name.toList()
----
-IMPORTANT: The Gremlin-Java `withBindings()` traversal source step is not needed. Gremlin-Java's model is only required
-in statically typed languages where bindings need to have the same typing as the `Traversal` API.
+NOTE: The Gremlin `withBindings()` traversal source step is not needed. This is only required
+in statically typed languages where bindings need to have the same typing as the `Traversal` API. However, if desired,
+it is possible to use the `withBindings()`-model as Gremlin-Python's `Bindings.of()` simply returns a 2-tuple of `(str,object)`
+(see <<connecting-via-remotegraph,`Bindings`>>).
The Lambda Solution
~~~~~~~~~~~~~~~~~~~
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ab252fc2/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
index 4619c18..4c307a3 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
@@ -113,6 +113,8 @@ under the License.
source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
return source
+ def withBindings(self, bindings):
+ return self
""")
pythonClass.append("\n\n")
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ab252fc2/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
index dbb9c3c..69c3051 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
@@ -252,10 +252,17 @@ class Bytecode(object):
def __repr__(self):
return str(self.source_instructions) + str(self.step_instructions)
+
'''
-BINDING
+BINDINGS
'''
+class Bindings(object):
+ def of(self,variable,value):
+ if not isinstance(variable, str):
+ raise TypeError("Variable must be str")
+ return (variable,value)
+
class Binding(object):
def __init__(self,variable,value):
self.variable = variable
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ab252fc2/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/__init__.py b/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
index 46e9609..2a5e832 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
@@ -34,5 +34,6 @@ from .traversal import Pop
from .traversal import Scope
from .traversal import T
from .traversal import Traversal
+from .traversal import Bindings
__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ab252fc2/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
index 8b3ff88..069762a 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
@@ -80,6 +80,9 @@ class GraphTraversalSource(object):
source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
return source
+ def withBindings(self, bindings):
+ return self
+
class GraphTraversal(Traversal):
def __init__(self, graph, traversal_strategies, bytecode):
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ab252fc2/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index ffb4548..60f5649 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -332,10 +332,17 @@ class Bytecode(object):
def __repr__(self):
return str(self.source_instructions) + str(self.step_instructions)
+
'''
-BINDING
+BINDINGS
'''
+class Bindings(object):
+ def of(self,variable,value):
+ if not isinstance(variable, str):
+ raise TypeError("Variable must be str")
+ return (variable,value)
+
class Binding(object):
def __init__(self,variable,value):
self.variable = variable