You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by da...@apache.org on 2017/02/28 15:48:31 UTC
[05/12] tinkerpop git commit: added standard message processor
added standard message processor
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3a14da2a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3a14da2a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3a14da2a
Branch: refs/heads/tp32
Commit: 3a14da2a7a6e948a827ea2979e99377b37bb846f
Parents: e6c7114
Author: davebshow <da...@gmail.com>
Authored: Wed Feb 15 14:25:28 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Tue Feb 28 10:30:48 2017 -0500
----------------------------------------------------------------------
.../src/main/jython/gremlin_python/driver/client.py | 5 +++++
.../main/jython/gremlin_python/driver/serializer.py | 10 ++++++++++
.../src/main/jython/tests/driver/test_client.py | 15 ++++++++++++++-
3 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3a14da2a/gremlin-python/src/main/jython/gremlin_python/driver/client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/client.py b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
index dec39bf..fcbdf07 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/client.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
@@ -110,5 +110,10 @@ class Client:
processor='traversal', op='bytecode',
args={'gremlin': message,
'aliases': {'g': self._traversal_source}})
+ elif isinstance(message, str):
+ message = request.RequestMessage(
+ processor='', op='eval',
+ args={'gremlin': message,
+ 'aliases': {'g': self._traversal_source}})
conn = self._pool.get(True)
return conn.write(message)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3a14da2a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
index 10dcfd3..2db7374 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
@@ -48,6 +48,16 @@ class GraphSONMessageSerializer:
_graphson_reader = graphson.GraphSONReader()
+
+ class standard(Processor):
+
+ def authentication(self, args):
+ return args
+
+ def eval(self, args):
+ return args
+
+
class traversal(Processor):
def authentication(self, args):
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3a14da2a/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index 2e0e96c..02582a1 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -35,13 +35,23 @@ def test_connection(connection):
assert len(results) == 6
assert isinstance(results, list)
-def test_client(client):
+
+def test_client_simple_eval(client):
+ assert client.submit('1 + 1').all().result()[0] == 2
+
+
+def test_client_eval_traversal(client):
+ assert len(client.submit('g.V()').all().result()) == 6
+
+
+def test_client_bytecode(client):
g = Graph().traversal()
t = g.V()
message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
result_set = client.submit(message)
assert len(result_set.all().result()) == 6
+
def test_iterate_result_set(client):
g = Graph().traversal()
t = g.V()
@@ -52,6 +62,7 @@ def test_iterate_result_set(client):
results += result
assert len(results) == 6
+
def test_client_async(client):
g = Graph().traversal()
t = g.V()
@@ -61,6 +72,7 @@ def test_client_async(client):
result_set = future.result()
assert len(result_set.all().result()) == 6
+
def test_connection_share(client):
# Overwrite fixture with pool_size=1 client
client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1)
@@ -78,6 +90,7 @@ def test_connection_share(client):
result_set = future.result()
assert len(result_set.all().result()) == 6
+
def test_multi_conn_pool(client):
g = Graph().traversal()
t = g.V()