tori.controller

Author:Juti Noppornpitak

This package contains an abstract controller (based on tornado.web.RequestHandler) and built-in controllers.

class tori.controller.Controller(*args, **kwargs)

The abstract controller for Tori framework which uses Jinja2 as a template engine instead of the default one that comes with Tornado.

component(name, fork_component=False)

Get the (re-usable) component from the initialized Imagination component locator service.

Parameters:
  • name – the name of the registered re-usable component.
  • fork_component – the flag to fork the component
Returns:

module, package registered or None

render(template_name, **contexts)

Render the template with the given contexts and push the output buffer.

See tori.renderer.Renderer.render() for more information.

render_template(template_name, **contexts)

Render the template with the given contexts.

See tori.renderer.Renderer.render() for more information.

session

Session Controller

Return type:tori.session.controller.Controller
template_engine

Template Engine

Return type:tori.template.renderer.Renderer
class tori.controller.ErrorController(*args, **kwargs)

Generates an error response with status_code for all requests.

class tori.controller.ResourceService(*args, **kwargs)

Resource service is to serve a static resource via HTTP/S protocol.

static add_pattern(pattern, base_path, enable_cache=False)

Add the routing pattern for the resource path prefix.

Parameters:
  • pattern – a routing pattern. It can be a Python-compatible regular expression.
  • base_path – a path prefix of the resource corresponding to the routing pattern.
  • enable_cache – a flag to indicate whether any loaded resources need to be cached on the first request.
get(path=None)

Get a particular resource.

Parameters:path – blocks of path used to composite an actual path.

Note

This method requires refactoring.

class tori.controller.RestController(*args, **kwargs)

Abstract REST-capable controller based on a single primary key.

create()

Create an entity.

delete(id=None)

Handle DELETE requests.

get(id=None)

Handle GET requests.

list()

Retrieve the list of all entities.

post(id=None)

Handle POST requests.

put(id=None)

Handle PUT requests.

remove(id)

Remove an entity with id.

retrieve(id)

Retrieve an entity with id.

update(id)

Update an entity with id.

Read the Docs v: v2.1
Versions
latest
v2.1
v2.0
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.