Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Added `idleConnectionTimeout` setting for Gremlin Driver and automatic closing of idle connections
* Enabled TCP Keep-Alive in GremlinServer.
* Updated Python GLV examples to use HTTP and to run as part of the integration tests.
* Fixed `gremlin-python` `to()` and `from_()` methods to wrap Vertex objects with `__.V()` for proper edge creation.

== TinkerPop 3.8.0 (Grix Greven)

Expand Down
4 changes: 2 additions & 2 deletions gremlin-python/src/main/python/examples/basic_gremlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def main():

# be sure to use a terminating step like next() or iterate() so that the traversal "executes"
# iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database)
g.V(v1).add_e('knows').to(__.V(v2)).property('weight', 0.75).iterate()
g.V(v1).add_e('knows').to(__.V(v3)).property('weight', 0.75).iterate()
g.V(v1).add_e('knows').to(v2).property('weight', 0.75).iterate()
g.V(v1).add_e('knows').to(v3).property('weight', 0.75).iterate()

# retrieve the data from the "marko" vertex
marko = g.V().has(VERTEX_LABEL, 'name', 'marko').values('name').next()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ..driver.remote_connection import RemoteStrategy
from .. import statics
from ..statics import long
from ..structure.graph import Vertex

log = logging.getLogger("gremlinpython")

Expand Down Expand Up @@ -506,7 +507,10 @@ def format_(self, *args):
return self

def from_(self, *args):
self.gremlin_lang.add_step("from", *args)
if len(args) == 1 and isinstance(args[0], Vertex):
self.gremlin_lang.add_step("from", __.V(args[0].id))
else:
self.gremlin_lang.add_step("from", *args)
return self

def group(self, *args):
Expand Down Expand Up @@ -943,7 +947,10 @@ def times(self, *args):
return self

def to(self, *args):
self.gremlin_lang.add_step("to", *args)
if len(args) == 1 and isinstance(args[0], Vertex):
self.gremlin_lang.add_step("to", __.V(args[0].id))
else:
self.gremlin_lang.add_step("to", *args)
return self

def toE(self, *args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def test_should_extract_id_from_vertex(self):

# Test edge creation with from/to vertices
from_to = g.add_e("Edge").from_(Vertex(1)).to(Vertex(2))
assert "g.addE('Edge').from(1).to(2)" == from_to.gremlin_lang.get_gremlin()
assert "g.addE('Edge').from(__.V(1)).to(__.V(2))" == from_to.gremlin_lang.get_gremlin()

# Test mergeE() with Vertex in dictionary
merge_map = {
Expand Down
Loading