The Request class

class pyspacegdn.requests.Request(spacegdn)

A generic request to SpaceGDN.

This class provides a base to build other request classes on, it can also be used on its own for very simple requests.

Request classes that build on this one should just use this class’s methods to set the path, GET and/or POST parameters. The fetch method can then be used to fetch the results.

Headers are handled autmatically. The request type is guessed by looking at the POST parameters. If there are no POST parameters, a GET request will be carried out when fetch is called.

All methods will return self.

Methods:
set_path()
Set the path to query
add_post_param()
Add a HTTP POST parameter
add_get_param()
Add a HTTP GET parameter
Request.fetch()
Fetch the result.
Attributes:
spacegdn
The pyspacegdn.SpaceGDN instance used to create this request
__init__(spacegdn)

Instantiate a new Request.

This should only be called by classes, functions or modules in pySpaceGDN.

add_get_param(key, value)

Add a HTTP GET parameter.

Arguments:
key
The key for the parameter
value
The value of the parameter
add_post_param(key, value)

Add a HTTP POST parameter.

Arguments:
key
The key for the parameter
value
The value of the parameter
fetch()

Execute the request and fetch the result.

The result will be returned as a pyspacegdn.Response object.

set_path(path)

Set the path this request will query.

The path should not start with a forward-slash, unless the resulting URL is intended to be http://endpoint.example//path.

Arguments:
path
The path this request should query

Related Topics

This Page