Commits

Ronny Pfannschmidt committed c9b05d1

better url for partial content puting

Comments (0)

Files changed (2)

     xjobspec = app.xjobstorage.get(xjobid=xjobid)
     return json_encode({'result': result, 'xjobspec': xjobspec})
 
-@app.route("/putpartialstdout", methods=['PUT'])
+@app.route("/<int:xjobid>/stdout", methods=['PUT'])
 def putpartial():
     s_token = request.headers['content-range']
     token = int(s_token)
-    data = json.loads(request.data)
-    (xjobid,) = data.keys()
     if not app.streamh.isactive(int(xjobid)):
         return text_response(app, ("Job is not active,"
                                    "registration must have failed "
                                    "or the job has completed"))
     else:
         try:
-            stdout = data[xjobid]
-            app.streamh.push(int(xjobid), stdout, explicit_token=token)
+            app.streamh.push(xjobid, request.data, explicit_token=token)
         except KeyError:
             return text_response(app, "Segment was already submitted")
         return text_response(app, "Stored.")
 
     def push_func(self, xjobid, stdout, token, prep):
         conn = prep['conn']
-        data = json_encode({xjobid: stdout})
-        response = conn.PUT("/putpartialstdout", data,
+        response = conn.PUT("/%s/stdout" % xjobid, stdout,
                             headers={'content-range': token})
         if not response.read() == "Stored.":
             # handle errors