Example #1
0
def update(context, request):
    # parse JSON data from the request
    try:
        values = json.decode(request.params.get("data", None), context)
    except:
        raise httpexceptions.HTTPBadRequest()

    # drop uuid from values
    if "uuid" in values:
        values.pop("uuid")

    # iterate through schema and update fields
    for interface in context.__provides__.interfaces():
        for name in getFieldNamesInOrder(interface):
            if name in values:
                field = interface[name].bind(context)
                field.validate(values[name])
                field.set(context, values[name])

    manager = request.registry.getUtility(IObjectManager)
    manager.update(context)

    return json.values(context)
Example #2
0
def read(context, request):
    return json.values(context)
Example #3
0
 def I_adapt_that_field_and_value_for_IJSONValue(self):
     from shaura_json import utils as json
     self.json_values = json.values(self.obj)