コード例 #1
0
ファイル: server.py プロジェクト: andrewfang/smap
def read_report(self, request, duplicate_error=True):
    """Read a Reporting object sent by the client.  Will validate the
    object and remove extra fields which are not specified in the
    schema.
    """
    obj = schema.filter_fields('Reporting', json.load(request.content))
    if not schema.validate("Reporting", obj):
        raise core.SmapSchemaException("Invalid Reporting object (does not validate)", 400)
    if duplicate_error and self.reports.get_report(obj['uuid']):
        raise core.SmapException("Report instance already exists!", 400)
    return obj
コード例 #2
0
def read_report(self, request, duplicate_error=True):
    """Read a Reporting object sent by the client.  Will validate the
    object and remove extra fields which are not specified in the
    schema.
    """
    obj = schema.filter_fields('Reporting', json.load(request.content))
    if not schema.validate("Reporting", obj):
        raise core.SmapSchemaException("Invalid Reporting object (does not validate)", 400)
    if duplicate_error and self.reports.get_report(obj['uuid']):
        raise core.SmapException("Report instance already exists!", 400)
    return obj
コード例 #3
0
ファイル: server.py プロジェクト: andrewfang/smap
 def render_GET(self, request):
     """The GET verb will return the representation of the
     requested report instance.
     """
     if self.inst:
         request.setHeader('Content-type', 'application/json')
         obj = schema.filter_fields('Reporting', self.inst)
         # print schema.validate('Reporting', obj)
         d = json.AsyncJSON(obj).startProducing(request)
         d.addBoth(lambda _: request.finish())
     else:
         request.setResponseCode(404)
         request.finish()
     return server.NOT_DONE_YET
コード例 #4
0
 def render_GET(self, request):
     """The GET verb will return the representation of the
     requested report instance.
     """
     if self.inst:
         request.setHeader('Content-type', 'application/json')
         obj = schema.filter_fields('Reporting', self.inst)
         # print schema.validate('Reporting', obj)
         d = json.AsyncJSON(obj).startProducing(request)
         d.addBoth(lambda _: request.finish())
     else:
         request.setResponseCode(404)
         request.finish()
     return server.NOT_DONE_YET