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.
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.
- lineage[source]¶
Lineage from current context to the root node.
Result: List of nodes. Return type: list of 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
- page_title[source]¶
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: unicode
- root[source]¶
The site root.
Result: The root object of the site. Return type: kotti.resources.Node
- kotti.views.util.and_(*clauses)¶
Produce a conjunction of expressions joined by AND.
E.g.:
from sqlalchemy import and_ stmt = select([users_table]).where( and_( users_table.c.name == 'wendy', users_table.c.enrolled == True ) )
The and_() conjunction is also available using the Python & operator (though note that compound expressions need to be parenthesized in order to function with Python operator precedence behavior):
stmt = select([users_table]).where( (users_table.c.name == 'wendy') & (users_table.c.enrolled == True) )
The and_() operation is also implicit in some cases; the Select.where() method for example can be invoked multiple times against a statement, which will have the effect of each clause being combined using and_():
stmt = select([users_table]).\ where(users_table.c.name == 'wendy').\ where(users_table.c.enrolled == True)
See also
- kotti.views.util.or_(*clauses)¶
Produce a conjunction of expressions joined by OR.
E.g.:
from sqlalchemy import or_ stmt = select([users_table]).where( or_( users_table.c.name == 'wendy', users_table.c.name == 'jack' ) )
The or_() conjunction is also available using the Python | operator (though note that compound expressions need to be parenthesized in order to function with Python operator precedence behavior):
stmt = select([users_table]).where( (users_table.c.name == 'wendy') | (users_table.c.name == 'jack') )
See also