Ejemplo n.º 1
0
def rest_read(request, callback=None):
    """Base method to handle read requests on the REST interface.
    Returns a JSON object of a specific item.

    :request: Current request
    :callback: Current function which is called after the item has been read.
    :returns: JSON object.
    """
    handle_callback(request, callback)
    return JSONResponse(True, get_item_from_request(request))
Ejemplo n.º 2
0
def read(request, callback=None, renderers=None):
    """Base method to handle read requests. Returns a dictionary of
    values used available in the rendererd template The template to
    render is defined in the view configuration.

    :request: Current request
    :callback: Current function which is called after the item has been read.
    :returns: Dictionary.
    """
    handle_history(request)
    handle_params(request)
    handle_callback(request, callback)
    rvalues = get_return_value(request)
    values = {'_roles': [str(r.name) for r in request.user.roles]}
    form = get_item_form('read', request, renderers, values=values)
    rvalues['form'] = render_item_form(request, form, values)
    return rvalues