pyams_viewlet
package ⊞¶
PyAMS_viewlet package
PyAMS viewlets management package
Subpackages¶
pyams_viewlet.manager
¶
PyAMS_viewlet.manager module
This module defines the viewlet manager, as weel as a “viewletmanager_config” decorator which can be used instead of ZCML to declare a viewlets manager.
-
class
pyams_viewlet.manager.
ConditionalViewletManager
(context, request, view)[source]¶ Bases:
pyams_viewlet.manager.WeightOrderedViewletManager
Conditional weight ordered viewlet managers
-
class
pyams_viewlet.manager.
TemplateBasedViewletManager
[source]¶ Bases:
object
Template based viewlet manager mixin class
-
template
= <BoundViewTemplate of None>¶
-
-
class
pyams_viewlet.manager.
ViewletManager
(context, request, view)[source]¶ Bases:
object
The Viewlet Manager base
A generic manager class which can be instantiated.
A viewlet manager can be used as mapping and can get to a given viewlet by it’s name.
-
filter
(viewlets)[source]¶ Filter out all content providers
Parameters: viewlets – list of viewlets, each element being a tuple of (name, viewlet) form Default implementation is filtering out viewlets for which a permission which is not granted to the current principal is defined.
-
permission
= None¶
-
sort
(viewlets)[source]¶ Sort the viewlets.
Parameters: viewlets – list of viewlets, each element being a tuple of (name, viewlet) form Default implementation is sorting viewlets by name
-
template
= None¶
-
viewlets
= None¶
-
-
pyams_viewlet.manager.
ViewletManagerFactory
(name, interface, bases=(), cdict=None)[source]¶ Viewlet manager factory
-
class
pyams_viewlet.manager.
WeightOrderedViewletManager
(context, request, view)[source]¶ Bases:
pyams_viewlet.manager.ViewletManager
Weight ordered viewlet managers.
Viewlets with the same weight are sorted by label
-
pyams_viewlet.manager.
get_weight_and_label
(item, request=None)[source]¶ Get sort weight and label of a given viewlet
-
class
pyams_viewlet.manager.
viewletmanager_config
(**settings)[source]¶ Bases:
object
Class or interface decorator used to declare a viewlet manager
You can provide same arguments as in ‘viewletManager’ ZCML directive: :param name: name of the viewlet; may be unique for a given viewlet manager :param view: the view class or interface for which viewlet is displayed :param for_: the context class or interface for which viewlet is displayed :param permission: name of a permission required to display the viewlet :param layer: request interface required to display the viewlet :param class_: the class handling the viewlet manager; if the decorator is applied
on an interface and if this argument is not provided, the viewlet manager will be handled by a default ViewletManager classParameters: provides – an interface the viewlet manager provides; if the decorator is applied on an Interface, this will be the decorated interface; if the decorated is applied on a class and if this argument is not specified, the manager will provide IViewletManager interface. -
venusian
= <module 'venusian' from '/home/docs/checkouts/readthedocs.org/user_builds/pyams/envs/latest/lib/python3.7/site-packages/venusian/__init__.py'>¶
-
pyams_viewlet.metaconfigure
¶
PyAMS_viewlet.metaconfigure module
This module provides ZCML directives handlers.
-
pyams_viewlet.metaconfigure.
ViewletDirective
(_context, name, class_, context=<InterfaceClass zope.interface.Interface>, layer=<InterfaceClass pyramid.interfaces.IRequest>, view=<InterfaceClass pyramid.interfaces.IView>, manager=<InterfaceClass pyams_viewlet.interfaces.IViewletManager>, attribute='render', permission=None, **kwargs)[source]¶ Viewlet ZCML directive
-
pyams_viewlet.metaconfigure.
ViewletManagerDirective
(_context, name, context=<InterfaceClass zope.interface.Interface>, layer=<InterfaceClass pyramid.interfaces.IRequest>, view=<InterfaceClass pyramid.interfaces.IView>, provides=<InterfaceClass pyams_viewlet.interfaces.IViewletManager>, class_=None, permission=None)[source]¶ Viewlet manager ZCML directive
pyams_viewlet.metadirectives
¶
PyAMS_viewlet.metadirectives module
This template provides definition of ZCML directives.
-
interface
pyams_viewlet.metadirectives.
IContentProvider
[source]¶ A directive to register a simple content provider.
Content providers are registered by their context (for attribute), the request (layer attribute) and the view (view attribute). They also must provide a name, so that they can be found using the TALES
provider
namespace. Other than that, content providers are just like any other views.-
view
¶ The view the content provider is registered for
The view can either be an interface or a class. By default the provider is registered for all views, the most common case.
Implementation: zope.configuration.fields.GlobalObject
Read Only: False Required: False Default Value: <InterfaceClass zope.interface.Interface>
-
name
¶ The name of the content provider
The name of the content provider is used in the TALES
provider
namespace to look up the content provider.Implementation: zope.schema.TextLine
Read Only: False Required: True Default Value: None Allowed Type: str
-
for_
¶ The interface or class this view is for
Implementation: zope.configuration.fields.GlobalObject
Read Only: False Required: False Default Value: None
-
permission
¶ Permission
The permission needed to use the view
Implementation: zope.schema.TextLine
Read Only: False Required: False Default Value: None Allowed Type: str
-
class_
¶ Class
A class that provides attributes used by the view
Implementation: zope.configuration.fields.GlobalObject
Read Only: False Required: False Default Value: None
-
layer
¶ The layer the view is in
A skin is composed of layers; layers are defined as interfaces, which are provided to the request when the skin is applied. It is common to put skin specific views in a layer named after the skin. If the ‘layer’ attribute is not supplied, it defaults to IRequest, which is the base interface of any request.
Implementation: zope.configuration.fields.GlobalInterface
Read Only: False Required: False Default Value: None Value Type
Implementation: zope.schema.InterfaceField
Read Only: False Required: True Default Value: None
-
-
interface
pyams_viewlet.metadirectives.
IViewletDirective
[source]¶ Extends:
pyams_viewlet.metadirectives.IContentProvider
A directive to register a new viewlet.
Viewlets are content providers that can only be displayed inside a viewlet manager. Thus they are additionally discriminated by the manager. Viewlets can rely on the specified viewlet manager interface to provide their content.
The viewlet directive also supports an undefined set of keyword arguments that are set as attributes on the viewlet after creation. Those attributes can then be used to implement sorting and filtering, for example.
-
manager
¶ Manager
The interface or class of the viewlet manager
Implementation: zope.configuration.fields.GlobalObject
Read Only: False Required: False Default Value: <InterfaceClass pyams_viewlet.interfaces.IViewletManager>
-
-
interface
pyams_viewlet.metadirectives.
IViewletManagerDirective
[source]¶ Extends:
pyams_viewlet.metadirectives.IContentProvider
A directive to register a new viewlet manager.
Viewlet manager registrations are very similar to content provider registrations, since they are just a simple extension of content providers. However, viewlet managers commonly have a specific provided interface, which is used to discriminate the viewlets they are providing.
-
provides
¶ The interface this viewlet manager provides
A viewlet manager can provide an interface, which is used to lookup its contained viewlets.
Implementation: zope.configuration.fields.GlobalInterface
Read Only: False Required: False Default Value: <InterfaceClass pyams_viewlet.interfaces.IViewletManager> Value Type
Implementation: zope.schema.InterfaceField
Read Only: False Required: True Default Value: None
-
pyams_viewlet.provider
¶
PyAMS_viewlet.provider module
This module provides the “provider:” TALES expression, which allows inclusion of any registered content provider into a Chameleon or ZPT template.
-
class
pyams_viewlet.provider.
ProviderExpr
(expression, braces_required=False)[source]¶ Bases:
pyams_utils.tales.ContextExprMixin
,chameleon.tales.StringExpr
provider: TALES expression
-
transform
= <Symbol value=<function render_content_provider> at 7ff6d6f6da20>¶
-
-
pyams_viewlet.provider.
render_content_provider
(econtext, name)[source]¶ TALES provider: content provider
This TALES expression is used to render a registered “content provider”, which is an adapter providing IContentProvider interface; adapter lookup is based on current context, request and view.
The requested provider can be called with our without arguments, like in ${structure:provider:my_provider} or ${structure:provider:my_provider(arg1, arg2)}. In the second form, arguments will be passed to the “update” method; arguments can be static (like strings or integers), or can be variables defined into current template context; other Python expressions including computations or functions calls are actually not supported, but dotted syntax is supported to access inner attributes of variables.
Provider arguments can be passed by position but can also be passed by name, using classic syntax as in ${structure:provider:my_provider(arg1, arg3=var3)}
pyams_viewlet.viewlet
¶
PyAMS_viewlet.viewlet module
This module provides base content providers and viewlets classes, as well as a decorators which can be used instead of ZCML declarations to register content providers and viewlets.
-
class
pyams_viewlet.viewlet.
BaseContentProvider
(context, request)[source]¶ Bases:
pyams_viewlet.viewlet.EmptyContentProvider
Base template based content provider
-
render
= <BoundViewTemplate of None>¶
-
resources
= ()¶
-
-
class
pyams_viewlet.viewlet.
EmptyContentProvider
(context, request)[source]¶ Bases:
object
Empty content provider base class
-
permission
= None¶
-
-
class
pyams_viewlet.viewlet.
EmptyViewlet
(context, request, view, manager)[source]¶ Bases:
object
Empty viewlet base class
-
permission
= None¶
-
-
class
pyams_viewlet.viewlet.
ViewContentProvider
(context, request, view)[source]¶ Bases:
pyams_viewlet.viewlet.BaseContentProvider
Template based content provider
-
class
pyams_viewlet.viewlet.
Viewlet
(context, request, view, manager)[source]¶ Bases:
pyams_viewlet.viewlet.EmptyViewlet
Viewlet adapter class used in meta directive as a mixin class.
-
render
= <BoundViewTemplate of None>¶
-
-
class
pyams_viewlet.viewlet.
contentprovider_config
(**settings)[source]¶ Bases:
object
Class decorator used to declare a content provider
You can provide same arguments as in ‘viewlet’ ZCML directive: @name = name of the viewlet; may be unique for a given viewlet manager @view = the view class or interface for which viewlet is displayed @for = the context class or interface for which viewlet is displayed @permission = name of a permission required to display the viewlet @layer = request interface required to display the viewlet
-
venusian
= <module 'venusian' from '/home/docs/checkouts/readthedocs.org/user_builds/pyams/envs/latest/lib/python3.7/site-packages/venusian/__init__.py'>¶
-
-
class
pyams_viewlet.viewlet.
viewlet_config
(**settings)[source]¶ Bases:
object
Class decorator used to declare a viewlet
You can provide same arguments as in ‘viewlet’ ZCML directive: @name = name of the viewlet; may be unique for a given viewlet manager @manager = manager class or interface holding the viewlet @view = the view class or interface for which viewlet is displayed @for = the context class or interface for which viewlet is displayed @permission = name of a permission required to display the viewlet @layer = request interface required to display the viewlet @weight = weight of the viewlet when using a weight ordered viewlet manager
-
venusian
= <module 'venusian' from '/home/docs/checkouts/readthedocs.org/user_builds/pyams/envs/latest/lib/python3.7/site-packages/venusian/__init__.py'>¶
-