def kv_update(request, kv_class, kv_pk):
    """
    POST to:
    /core/keyvalue/api/<kv_class>/<kv_pk>/update/

    with parameters like:

    {
        'key': 'key_string'
        'value': 'value_string'
        'obj_pk': 1
    }
    Status Codes:
        * 200 - Object updated
        * 400 - Issues during update
    """
    key, value, errors = get_kv(request)
    if errors:
        return HttpResponse(
            status=400, content=json.dumps(
                {'success': False, 'message': errors}
            )
        )
    Klass = resolve_class(kv_class)
    KVKlass = Klass.keyvalue_set.related.model
    try:
        kv = KVKlass.objects.get(pk=kv_pk)
    except KVKlass.DoesNotExist:
        return HttpResponse(
            status=404, content=json.dumps({'success': False})
        )
    try:
        kv.key = key
        kv.value = value
        kv.clean()
        kv.save()
        resp = {
            'status': 200,
            'content': json.dumps(
                {'success': True, 'key': kv.key, 'value': kv.value}
            )
        }
    except __HOLE__, e:
        resp = {
            'status': 400,
            'content': json.dumps({'success': False, 'message': str(e)})
        }
    return HttpResponse(**resp)
dataset/ETHPy150Open mozilla/inventory/core/keyvalue/api.py/kv_update