class kotti.views.util.TemplateAPI(context, request, bare=None, **kwargs)[source]

Bases: object

This implements the api object that’s passed to all templates.

Use dict-access as a shortcut to retrieve template macros from templates.

static is_location(context)[source]

Does context implement pyramid.interfaces.ILocation?

Parameters:context (kotti.interfaces.INode) – The context.
Return type:bool
Returns:True if Is the context object implements pyramid.interfaces.ILocation.

The site title.

Result:Value of the kotti.site_title setting (if specified) or the root item’s title attribute.
Return type:str

Title for the current page as used in the <head> section of the default master.pt template.

Result:‘[Human readable view title ]``context.title`` - site_title()’’
Return type:str
url(context=None, *elements, **kwargs)[source]

URL construction helper. Just a convenience wrapper for pyramid.request.resource_url() with the same signature. If context is None the current context is passed to resource_url.


The site root.

Result:The root object of the site.
Return type:kotti.resources.Node

The root node for the navigation.

Result:Nearest node in the lineage() that provides kotti.interfaces.INavigationRoot or root() if no node provides that interface.
Return type:kotti.resources.Node

Lineage from current context to the root node.

Result:List of nodes.
Return type:list of kotti.resources.Node

List of nodes from the navigation_root() to the context.

Result:List of nodes.
Return type:list of kotti.resources.Node
has_permission(permission, context=None)[source]

Convenience wrapper for pyramid.security.has_permission() with the same signature. If context is None the current context is passed to has_permission.

static inside(resource1, resource2)

Is resource1 ‘inside’ resource2? Return True if so, else False.

resource1 is ‘inside’ resource2 if resource2 is a lineage ancestor of resource1. It is a lineage ancestor if its parent (or one of its parent’s parents, etc.) is an ancestor.

static sanitize(html, sanitizer='default')[source]

Convenience wrapper for kotti.sanitizers.sanitize().

  • html (str) – HTML to be sanitized
  • sanitizer (str) – name of the sanitizer to use.

sanitized HTML

Return type:



Pyramid includeme hook.

Parameters:config (pyramid.config.Configurator) – app config