Routing

Along with needing to have controllers, an app also has to have routes to those controllers. There is a provided auto route function, described below, that will generate the route pattern based off of the file hierarchy of where the controller which is decorated is located at. If you prefer to make your own routes, then you can use the described RouteContainer along with the route tables add_route() to make your own routes.

seshat.route_containers.controller_folder = ''

The folder where the controllers are located in. Since the auto route generation uses folder hierarchy, this setting allows to you to have controllers in a single folder but not have that folder end up as the route prefix.

seshat.route.route()[source]

Class decorator that will take and generate a route table entry for the decorated controller class, based off of its name and its file hierarchy

Use like so:

from seshat.controller import BaseController
from seshat.route import route

@route()
class index(BaseController):
    pass

which will result in a route for “/” being made for this controller.

controllers whose name is index automatically get routed to the root of their folders, so an index controller in “profiles/” will have a route that looks like “/profiles”

Controllers whose name is view will automatically get routed to any index route that has an attached ID. Eg:

# In folder: profiles/
class view(BaseController):
  pass

will be routed to if the request URL is “/profiles/5” and the resulting id will be stored in self.request.id

class seshat.route_containers.RouteContainer(url, controller)[source]

Provides a base route table entry which can either be used by itself or inherited from to make a custom process for making a route.

Eg of use is the AutoRouteContainer which is used in conjunction with the route() decocrator to automatically generate a route url.

controller = None

The controller object, of type BaseController which this route represents

Type:BaseController
url = None

The actual url pattern for which this route is for. :type: str