request¶
- 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.
- class seshat.request.Request(env)[source]¶
Represents the request from the server, and contains various information and utilities.
- env = None¶
The raw environ dict which is provided by the wsgi server.
- method = None¶
The HTTP method by which the request was made, in all caps.
- remote = None¶
The clients IP, otherwise Unknown IP This is set from HTTP_X_REAL_IP which is a header that I personally have nginx append to the request before handing it to Seshat.
- headers = None¶
Headers which were sent with the request, in the form of a .RequestHeaders object
- url_params = None¶
When a match is made in the route table, this is set to a dict containing the matched pattern groups in the url.
- 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
- class seshat.headers.RequestHeaders(env=None)[source]¶
A basic container for all the headers in an HTTP request. Acts like a dictionary.
- referer = None¶
The referrer address which this request originated from. If no referrer is present this will return None
- referrer = None¶
The referrer address which this request originated from. If no referrer is present this will return None
- user_agent = None¶
The user agent, unparsed, or the string Unknown User Agent
Note
This will probably change to a parsed result class later on.
Returns an Authorization instance if there is an Authorization header in the request. Otherwise this returns None
- class seshat.headers.Authorization(auth_type, **kwargs)[source]¶
Basic little class to help represent an Authorization header. Currently only supports HTTP Basic Auth but support for digest auth is slated for later.
This class is mostly unfinished at this time.
- class seshat.headers.Accept(s)[source]¶
Basic class which can represent any number of the accept headers which commonly take on the form of: type/subtype; q=int