BaseRequest

class seshat.request.FileObject(file_obj)[source]

Provides a File like object which supports the common file operations, along with providing some additional metadata which is sent from the client.

read()[source]
readline()[source]
seek(where)[source]
readlines()[source]
auto_read()[source]
class seshat.request.BaseRequest(env)[source]

Represents the request from the server, and contains various information and utilities. Also the place to store the session object.

cookie_name = 'sid'

The name of the cookie

url = None

A urlparse result of the requests path

method = None

The HTTP method by which the request was made, in all caps.

remote = None

The clients IP, otherwise Unknown IP

user_agent = None

The user agent, unparsed, or the string Unknown User Agent

referer = None

The referal URL if it exists, otherwise an empty string.

accepts(t)[source]

Determines if the given mimetype is accepted by the client.

get_param(parameter, default='', cast=<type 'str'>)[source]

Allows you to get a parameter from the request. If the parameter does not exist, or is empty, then a default will be returned. You can also choose to optionally cast the parameter.

If a parameter has multiple values then this will return a list of all those values.

Parameters:
  • parameter – The name of the parameter to get
  • default – The default to return if the parameter is nonexistent or empty
  • cast – An optional cast for the parameter.
get_file(name)[source]

Along with getting parameters, one may wish to retrieve other data such as files sent.

This provides an interface for getting a file like FileObject which can be used like a normal file but also holds some meta data sent with the request. If no file by the given name is found then this will return None

build_session()[source]

Called during the objects instantiation. Override to set the requests session property.

build_cfg()[source]

Called during the objects instantiation. Override to set the requests cfg property.

log(head)[source]

Called right at the end of the request when the response is being returned to the client. This is useful for logging to a database or log file.

Parameters:head – The reponses Head object which was returned to the client.