kotti.views.util¶
- 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
.
- site_title¶
The site title.
- Result
Value of the
kotti.site_title
setting (if specified) or the root item’stitle
attribute.- Return type
str
- page_title¶
Title for the current page as used in the
<head>
section of the defaultmaster.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. Ifcontext
isNone
the current context is passed toresource_url
.
- root¶
The site root.
- Result
The root object of the site.
- Return type
The root node for the navigation.
- Result
Nearest node in the
lineage()
that provideskotti.interfaces.INavigationRoot
orroot()
if no node provides that interface.- Return type
- lineage¶
Lineage from current context to the root node.
- Result
List of nodes.
- Return type
list of
kotti.resources.Node
- breadcrumbs¶
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. Ifcontext
isNone
the current context is passed tohas_permission
.
- static inside(resource1, resource2)¶
Is
resource1
‘inside’resource2
? ReturnTrue
if so, elseFalse
.resource1
is ‘inside’resource2
ifresource2
is a lineage ancestor ofresource1
. 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()
.- Parameters
html (str) – HTML to be sanitized
sanitizer (str) – name of the sanitizer to use.
- Result
sanitized HTML
- Return type
str
- kotti.views.util.includeme(config)[source]¶
Pyramid includeme hook.
- Parameters
config (
pyramid.config.Configurator
) – app config