Miscellaneous view helpers

Helper functions for view handlers.

All items in this module can be imported directly from coaster.views.


Return the current URL including the query string as a relative path. If the app uses subdomains, return an absolute path

coaster.views.misc.get_next_url(referrer=False, external=False, session=False, default=[])[source]

Get the next URL to redirect to. Don’t return external URLs unless explicitly asked for. This is to protect the site from being an unwitting redirector to external URLs. Subdomains are okay, however.

This function looks for a next parameter in the request or in the session (depending on whether parameter session is True). If no next is present, it checks the referrer (if enabled), and finally returns either the provided default (which can be any value including None) or the script root (typically /).

coaster.views.misc.jsonp(*args, **kw)[source]

Returns a JSON response with a callback wrapper, if asked for.