S
smisk

mvc

Model-View-Controller framework for Smisk. Provides URL routing, template rendering, leaf filters, and a rich Application base class.

Configuration parameters

smisk.mvc.template_dir

Path to the template directory, relative to the application directory.

smisk.mvc.forks

Number of worker processes to fork. Defaults to 0.

Leaf filters

Leaf filters are callables that post-process controller return values before serialization. Register them via Application.leaf_filters.

Functions

smisk.mvc.environment()

Returns a dict describing the current runtime environment (version, paths, etc.).

smisk.mvc.main(application_class=None, *args, **kwargs)

Convenience entry point. Instantiates application_class, configures it from command-line arguments, and calls run().

smisk.mvc.run(application_class, *args, **kwargs)

Alias for main().

smisk.mvc.setup()

Set up the MVC subsystem without starting the server. Useful for testing.

Classes

class smisk.mvc.Application(smisk.core.Application)

The MVC application. Handles routing, dispatch, template rendering, and serialization.

templates

Template engine instance.

routes

Routing table.

serializer

Default serializer for responses.

leaf_filters

List of callables applied to controller return values before serialization.

unicode_errors

Error handling mode for unicode encoding. Defaults to 'replace'.

autoclear_model_session

If True, the SQLAlchemy session is cleared after each request.

run()

Start the FastCGI event loop.

service()

Called for each request. Performs routing and dispatches to the appropriate controller leaf.

setup()

Initialise MVC subsystems. Called automatically before the first request.

error(typ, val, tb)

Handle an error. Delegates to smisk.core.Application.error() unless overridden.

call_action(leaf, *args, **kwargs)

Call a controller leaf and apply leaf filters.

encode_response(value)

Serialize a controller return value.

parse_request()

Parse the incoming request and populate request.get / request.post.

response_serializer()

Determine the best serializer for the current request based on content negotiation.

send_response(value)

Serialize and send value as the response body.

class smisk.mvc.Request(smisk.core.Request)

Extended request with MVC-specific attributes.

serializer

The serializer selected for this request (may be None).

cn_url

The canonical URL of the matched route.

class smisk.mvc.Response(smisk.core.Response)

Extended response with serialization helpers.

format

Explicit response format override (e.g. "json"). Bypasses content negotiation.

serializer

The serializer to use for this response. If None, strict TCN applies.

fallback_serializer

Serializer used when content negotiation fails.

charset

Character set for the response. Determined automatically from mimetypes.guess_type when possible.

send_file(path)

Send a file to the client. Inherited from smisk.core.Response.