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/07d20646
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/07d20646
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/07d20646

Branch: refs/heads/TINKERPOP-1599
Commit: 07d2064677db405493c7963a937dcbcd4f502b20
Parents: 949ed56
Author: davebshow <davebs...@gmail.com>
Authored: Wed Feb 15 14:25:28 2017 -0500
Committer: davebshow <davebs...@gmail.com>
Committed: Fri Feb 17 11:36:57 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/07d20646/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/07d20646/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/07d20646/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()

Reply via email to