You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/09/25 00:08:08 UTC

[18/22] tinkerpop git commit: TINKERPOP-1913 Added status attributes to ResultSet for python

TINKERPOP-1913 Added status attributes to ResultSet for python


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/49b1507f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/49b1507f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/49b1507f

Branch: refs/heads/master
Commit: 49b1507fdcf15bed2667beb205357cb44a4d57e8
Parents: bb01d96
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 18 15:06:46 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 15:06:46 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                          | 7 +++----
 .../src/main/jython/gremlin_python/driver/protocol.py       | 1 +
 .../src/main/jython/gremlin_python/driver/resultset.py      | 9 +++++++++
 gremlin-python/src/main/jython/tests/driver/test_client.py  | 3 +++
 4 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index e1b75dd..386f0d9 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -38,11 +38,10 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
 * Modified Gremlin Server to return a "host" status attribute on responses.
-* Added ability to the Java driver to retrieve status attributes returned from the server on the `ResultSet` object.
-* Modified remote traversals to retreive status attributes from traversal side-effects.
+* Added ability to the Java, .NET and Python drivers to retrieve status attributes returned from the server on the `ResultSet` object.
+* Modified remote traversals to retrieve status attributes from traversal side-effects.
 * Deprecated two `submit()`-related methods on the Java driver `Client` class.
-* Modified Gremlin.Net `ResponseException` to include status code and status attributes.
-* Modified Java driver's `ResponseException` to include status code and status attributes.
+* Modified Java and Gremlin.Net `ResponseException` to include status code and status attributes.
 * Modified the return type for `IGremlinClient.SubmitAsync()` to be a `ResultSet` rather than an `IReadOnlyCollection`.
 * Added `Client.submit()` overloads that accept per-request `RequestOptions`.
 * Added sparql-gremlin.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index e0a2f7e..96174e0 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -90,6 +90,7 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
         elif status_code in [200, 206]:
             result_set.stream.put_nowait(data)
             if status_code == 200:
+                result_set.status_attributes = message['status']['attributes']
                 del results_dict[request_id]
             return status_code
         else:

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
index cfdca5b..76e5029 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
@@ -28,6 +28,7 @@ class ResultSet:
         self._request_id = request_id
         self._done = None
         self._aggregate_to = None
+        self._status_attributes = {}
 
     @property
     def aggregate_to(self):
@@ -38,6 +39,14 @@ class ResultSet:
         self._aggregate_to = val
 
     @property
+    def status_attributes(self):
+        return self._status_attributes
+
+    @status_attributes.setter
+    def status_attributes(self, val):
+        self._status_attributes = val
+
+    @property
     def request_id(self):
         return self._request_id
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/49b1507f/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 fbfe2d7..44dc3a7 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -19,6 +19,7 @@ under the License.
 import pytest
 
 from gremlin_python.driver.client import Client
+from gremlin_python.driver.protocol import GremlinServerError
 from gremlin_python.driver.request import RequestMessage
 from gremlin_python.process.graph_traversal import __
 from gremlin_python.structure.graph import Graph
@@ -35,6 +36,8 @@ def test_connection(connection):
     results = future.result()
     assert len(results) == 6
     assert isinstance(results, list)
+    assert results_set.done.done()
+    assert 'host' in results_set.status_attributes
 
 
 def test_client_simple_eval(client):