Viewlet Managers¶
Content Provider Manager implementation
-
class
zope.viewlet.manager.
ViewletManagerBase
(context, request, view)[source]¶ Bases:
object
The Viewlet Manager Base
A generic manager class which can be instantiated.
-
template
= None¶ A callable that will be used by
render
, if present, to produce the output. It will be passed the list of viewlets in the viewlets keyword argument.
-
get
(name, default=None)[source]¶ Return a viewlet registered for this object having the given name.
This takes into account security.
If no such viewlet can be found, returns default.
-
filter
(viewlets)[source]¶ Filter viewlets down from all available viewlets to just the currently desired set.
Parameters: viewlets (list) – a list of tuples of the form (name, viewlet)
.Returns: A list of the available viewlets in the form (name, viewlet)
. By default, this method checks withzope.security.checker.canAccess
to see if therender
method of a viewlet can be used to determine availability.
-
sort
(viewlets)[source]¶ Sort the viewlets.
viewlets
is a list of tuples of the form (name, viewlet).
-
update
()[source]¶ Update the viewlet manager for rendering.
This method is part of the protocol of a content provider, called before
render()
. This implementation will use it to:- Find the total set of available viewlets by querying for viewlet adapters.
- Filter the total set down to the active set by using
filter()
. - Sort the active set using
sort()
. - Provide viewlets that implement
ILocation
with a name. - Set
viewlets
to the found set of active viewlets. - Fire
BeforeUpdateEvent
for each active viewlet before callingupdate()
on it.
See also
zope.contentprovider.interfaces.IContentProvider
-
-
zope.viewlet.manager.
ViewletManager
(name, interface, template=None, bases=())[source]¶ Create and return a new viewlet manager class that implements
zope.viewlet.interfaces.IViewletManager
.Parameters:
-
class
zope.viewlet.manager.
WeightOrderedViewletManager
(context, request, view)[source]¶ Bases:
zope.viewlet.manager.ViewletManagerBase
Weight ordered viewlet managers.
-
sort
(viewlets)[source]¶ Sort the viewlets based on their
weight
attribute (if present; viewlets without aweight
are sorted at the beginning but are otherwise unordered).
-
render
()[source]¶ Just like
ViewletManagerBase()
, except that if there are no active viewlets inviewlets
, we will not attempt to render the template.
-
-
class
zope.viewlet.manager.
ConditionalViewletManager
(context, request, view)[source]¶ Bases:
zope.viewlet.manager.WeightOrderedViewletManager
Conditional weight ordered viewlet managers.