Index: gm/rebaseline_server/server.py |
=================================================================== |
--- gm/rebaseline_server/server.py (revision 11659) |
+++ gm/rebaseline_server/server.py (working copy) |
@@ -79,6 +79,11 @@ |
self._port = port |
self._export = export |
+ def is_exported(self): |
+ """ Returns true iff HTTP clients on other hosts are allowed to access |
+ this server. """ |
+ return self._export |
+ |
def fetch_results(self): |
""" Create self.results, based on the expectations in |
self._expectations_dir and the latest actuals from skia-autogen. |
@@ -150,8 +155,24 @@ |
TODO(epoger): Unless we start making use of result_type, remove that |
parameter.""" |
print 'do_GET_results: sending results of type "%s"' % result_type |
+ # TODO(epoger): Cache response_dict rather than the results object, to save |
+ # time on subsequent fetches (no need to regenerate the header, etc.) |
response_dict = _SERVER.results.GetAll() |
if response_dict: |
+ response_dict["header"] = { |
+ # Hash of testData, which the client must return with any edits-- |
+ # this ensures that the edits were made to a particular dataset. |
+ "data-hash": str(hash(repr(response_dict["testData"]))), |
+ |
+ # Whether the server will accept edits back. |
+ # TODO(epoger): Not yet implemented, so hardcoding to False; |
+ # once we implement the "browseonly" mode discussed in |
+ # https://codereview.chromium.org/24274003/#msg6 , this value will vary. |
+ "isEditable": False, |
+ |
+ # Whether the service is accessible from other hosts. |
+ "isExported": _SERVER.is_exported(), |
+ } |
self.send_json_dict(response_dict) |
else: |
self.send_error(404) |