helpers

New in version 1.1.0.

All members of this module is exported in smisk.mvc.

smisk.mvc.helpers.compose_query(params) → str

Convert a mapping object to a URL encoded query string.

The opposite can be found in smisk.core.URL.decompose_query().

Parameters:
  • params (dict) –
smisk.mvc.helpers.redirect_to(url, entity=None, status=http.Found, **params)

Redirect the requesting client to someplace else.

url can be a string or URL representing a absolute url, relative path or absolute path. Should not include query string information (even though it is possible), but instead use params for this purpose.

entity should be a Entity instance or a collection of Entity instances. The primary keys of these entities are added to params along with the actual values.

params are composed into a query string and added to the final location.

status is the type of HTTP status message to be used. Must be a subclass of Status3xx.

Note

The implementation of this function raises an exception to execute the redirection, thus calling this function in your action effectively finalizes the current HTTP transaction.