Aspen

A Python web framework that makes the most of the filesystem.
Simplates are the main attraction.

Website

Aspen creates an instance of aspen.website.Website when it starts up. It holds all of the global configuration for your application. It is placed in the namespace of your simplates, where it is available from the first page onwards. The following attributes are defined based on configuration in the environment (ASPEN_NAME) and keyword arguments to Website:

attributedefault
base_url''
changes_reloadFalse
charset_dynamicUTF-8
charset_staticNone
indices['index', 'index.html', 'index.json', 'index.html.spt', 'index.json.spt']
list_directoriesFalse
logging_threshold0 (most verbose)
media_type_defaulttext/plain
media_type_jsonapplication/json
project_rootNone
renderer_defaultstdlib_percent
show_tracebacksFalse
colorize_tracebacksFalse
www_rootNone
unavailable0

Computations

The following computations are performed after environment and keyword argument configuration is processed.

After your configuration scripts are run, Aspen looks at the value for unavailable, and if it’s greater than zero it installs a handler that returns 503 Service Unavailable for all requests. The value of unavailable is interpreted as the number of minutes of downtime you expect, and the Retry-After header is set accordingly. You can access the header as a datetime.datetime object at website.retry_after.

Methods

Here are the methods on the Website object:

def redirect(self, location, code=None, permanent=False, base_url=None, response=None):
    """Raise a redirect Response.

    If code is None then it will be set to 301 (Moved Permanently) if
    permanent is True and 302 (Found) if it is False. If url doesn't start
    with base_url (defaulting to self.base_url), then we prefix it with
    base_url before redirecting. This is a protection against open
    redirects. If you provide your own response we will set .code and
    .headers['Location'] on it.

    """
Home