resource Module

restkit.resource

This module provide a common interface for all HTTP request.

class restkit.resource.Resource(uri, **client_opts)

Bases: object

A class that can be instantiated for access to a RESTful resource, including authentication.

basic_auth_url = True
charset = 'utf-8'
clone()

if you want to add a path to resource uri, you can do:

resr2 = res.clone()
delete(path=None, headers=None, params_dict=None, **params)

HTTP DELETE

see GET for params description.

encode_keys = True
get(path=None, headers=None, params_dict=None, **params)

HTTP GET

  • path: string additionnal path to the uri
  • headers: dict, optionnal headers that will
    be added to HTTP request.
  • params: Optionnal parameterss added to the request.
head(path=None, headers=None, params_dict=None, **params)

HTTP HEAD

see GET for params description.

make_headers(headers)
make_params(params)
post(path=None, payload=None, headers=None, params_dict=None, **params)

HTTP POST

  • payload: string passed to the body of the request
  • path: string additionnal path to the uri
  • headers: dict, optionnal headers that will
    be added to HTTP request.
  • params: Optionnal parameterss added to the request
put(path=None, payload=None, headers=None, params_dict=None, **params)

HTTP PUT

see POST for params description.

request(method, path=None, payload=None, headers=None, params_dict=None, **params)

HTTP request

This method may be the only one you want to override when subclassing restkit.rest.Resource.

  • payload: string or File object passed to the body of the request
  • path: string additionnal path to the uri
  • headers: dict, optionnal headers that will
    be added to HTTP request.
Params_dict:Options parameters added to the request as a dict
  • params: Optionnal parameterss added to the request
response_class

alias of Response

safe = '/:'
unauthorized(response)
update_uri(path)

to set a new uri absolute path