actions¶
Actions allow you to write code that looks like:
class RandomController(Controller):
def GET(self):
return Redirect("/")
This module provides a few common Action classes to use, along with a base Action class which can be inherited to create your own Actions by overriding the __init__ function.
- class seshat.actions.Action[source]¶
Provides a base for creating a new object which represents an HTTP Status code.
All returned data is checked if it is of type Action and if so, the data/actions head is returned rather than the controllers head. This allows for a syntax like:
return NotFound()
which will cause the controller to return a 404 status code.
To create a new action, inherit this class then make a new __init__(self, *kargs) which sets self.response to a Reponse object (or just call super), and adds any headers or status changes to that Response object.
- class seshat.actions.Redirect(loc)[source]¶
Returns a 303 See Other status code along with a location header back to the client.
Parameters: loc (str) – The location to which the client should be redirect to
Returns a 401 UNAUTHORIZED back to the client
This should probably also include a WWW-Authenticate header, but I’ll leave that for later right now.