Пример #1
0
def activity_state_get(req_dict):
    # add ETag for concurrency
    actstate = ActivityStateManager(req_dict)
    stateId = req_dict['params'].get('stateId', None) if 'params' in req_dict else None
    if stateId: # state id means we want only 1 item
        resource = actstate.get()
        if resource.state:
            response = HttpResponse(resource.state.read(), content_type=resource.content_type)
        else:
            response = HttpResponse(resource.json_state, content_type=resource.content_type)
        response['ETag'] = '"%s"' %resource.etag
    else: # no state id means we want an array of state ids
        resource = actstate.get_ids()
        response = HttpResponse(json.dumps([k for k in resource]), content_type="application/json")
    return response
Пример #2
0
def activity_state_delete(req_dict):
    actstate = ActivityStateManager(req_dict)
    # Delete state
    actstate.delete()
    return HttpResponse('', status=204)
Пример #3
0
def activity_state_put(req_dict):
    # test ETag for concurrency
    actstate = ActivityStateManager(req_dict)
    actstate.put()

    return HttpResponse("", status=204)