Package restkit :: Module resource :: Class Resource
[hide private]
[frames] | no frames]

Class Resource

source code

object --+
         |
        Resource

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

Nested Classes [hide private]
  pool_class
Instance Methods [hide private]
 
__init__(self, uri, headers=None, **client_opts)
Constructor for a `Resource` object.
source code
 
__repr__(self)
repr(x)
source code
 
add_filter(self, f)
add an htt filter
source code
 
remmove_filter(self, f)
remove an http filter
source code
 
clone(self)
if you want to add a path to resource uri, you can do:
source code
 
__call__(self, path)
if you want to add a path to resource uri, you can do:
source code
 
get(self, path=None, headers=None, **params)
HTTP GET
source code
 
head(self, path=None, headers=None, **params)
HTTP HEAD
source code
 
delete(self, path=None, headers=None, **params)
HTTP DELETE
source code
 
post(self, path=None, payload=None, headers=None, **params)
HTTP POST
source code
 
put(self, path=None, payload=None, headers=None, **params)
HTTP PUT
source code
 
do_request(self, url, method='GET', payload=None, headers=None) source code
 
request(self, method, path=None, payload=None, headers=None, **params)
HTTP request
source code
 
update_uri(self, path)
to set a new uri absolute path
source code
 
_make_uri(self, base, *path, **query)
Assemble a uri based on a base, any number of path segments, and query string parameters.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  charset = 'utf-8'
  encode_keys = True
  safe = '/:'
  max_connections = 4
  basic_auth_url = True
  add_authorization = <Deprecated attribute add_authorization: <...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, uri, headers=None, **client_opts)
(Constructor)

source code 
Constructor for a `Resource` object.

Resource represent an HTTP resource.

:param uri: str, full uri to the server.
:param headers: dict, optionnal headers that will
    be added to HTTP request.
:param client_opts: `restkit.client.HttpConnection` Options

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

clone(self)

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

.. code-block:: python

    resr2 = res.clone()

__call__(self, path)
(Call operator)

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

.. code-block:: python

    Resource("/path").get()

get(self, path=None, headers=None, **params)

source code 
HTTP GET         

:param path: string  additionnal path to the uri
:param headers: dict, optionnal headers that will
    be added to HTTP request.
:param params: Optionnal parameterss added to the request.

head(self, path=None, headers=None, **params)

source code 

HTTP HEAD

see GET for params description.

delete(self, path=None, headers=None, **params)

source code 

HTTP DELETE

see GET for params description.

post(self, path=None, payload=None, headers=None, **params)

source code 
HTTP POST

:param payload: string passed to the body of the request
:param path: string  additionnal path to the uri
:param headers: dict, optionnal headers that will
    be added to HTTP request.
:param params: Optionnal parameterss added to the request

put(self, path=None, payload=None, headers=None, **params)

source code 

HTTP PUT

see POST for params description.

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

source code 
HTTP request

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

:param payload: string or File object passed to the body of the request
:param path: string  additionnal path to the uri
:param headers: dict, optionnal headers that will
    be added to HTTP request.
:param params: Optionnal parameterss added to the request


Class Variable Details [hide private]

add_authorization

Value:
<Deprecated attribute add_authorization: <function add_filter at 0x102\
0fcc08>>