Back to index

plone3  3.1.7
Public Member Functions
plone.app.viewletmanager.manager.BaseOrderedViewletManager Class Reference
Inheritance diagram for plone.app.viewletmanager.manager.BaseOrderedViewletManager:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def filter
def sort
def render

Detailed Description

Definition at line 22 of file manager.py.


Member Function Documentation

Filter the viewlets.
    
``viewlets`` is a list of tuples of the form (name, viewlet).

This filters the viewlets just like Five, but also filters out
viewlets by name from the local utility which implements the
IViewletSettingsStorage interface.

Definition at line 23 of file manager.py.

00023 
00024     def filter(self, viewlets):
00025         """Filter the viewlets.
00026     
00027         ``viewlets`` is a list of tuples of the form (name, viewlet).
00028 
00029         This filters the viewlets just like Five, but also filters out
00030         viewlets by name from the local utility which implements the
00031         IViewletSettingsStorage interface.
00032         """
00033         storage = getUtility(IViewletSettingsStorage)
00034         skinname = self.context.getCurrentSkinName()
00035         hidden = frozenset(storage.getHidden(self.__name__, skinname))
00036         results = []
00037         # Only return visible viewlets accessible to the principal
00038         # We need to wrap each viewlet in its context to make sure that
00039         # the object has a real context from which to determine owner
00040         # security.
00041         # Copied from Five
00042         for name, viewlet in viewlets:
00043             viewlet = viewlet.__of__(viewlet.context)
00044             if name not in hidden and guarded_hasattr(viewlet, 'render'):
00045                 results.append((name, viewlet))
00046         return results

Here is the caller graph for this function:

Reimplemented in plone.app.viewletmanager.manager.OrderedViewletManager.

Definition at line 76 of file manager.py.

00076 
00077     def render(self):
00078         if self.template:
00079             return self.template(viewlets=self.viewlets)
00080         else:
00081             return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
00082 

Sort the viewlets.

``viewlets`` is a list of tuples of the form (name, viewlet).

This sorts the viewlets by the order looked up from the local utility
which implements the IViewletSettingsStorage interface. The remaining
ones are sorted just like Five does it.

Definition at line 47 of file manager.py.

00047 
00048     def sort(self, viewlets):
00049         """Sort the viewlets.
00050 
00051         ``viewlets`` is a list of tuples of the form (name, viewlet).
00052 
00053         This sorts the viewlets by the order looked up from the local utility
00054         which implements the IViewletSettingsStorage interface. The remaining
00055         ones are sorted just like Five does it.
00056         """
00057 
00058         storage = getUtility(IViewletSettingsStorage)
00059         skinname = self.context.getCurrentSkinName()
00060         order_by_name = storage.getOrder(self.__name__, skinname)
00061         # first get the known ones
00062         name_map = dict(viewlets)
00063         result = []
00064         for name in order_by_name:
00065             if name in name_map:
00066                 result.append((name, name_map[name]))
00067                 del name_map[name]
00068 
00069         # then sort the remaining ones
00070         # Copied from Five
00071         remaining = sorted(name_map.items(),
00072                            lambda x, y: cmp(aq_base(x[1]), aq_base(y[1])))
00073 
00074         # return both together
00075         return result + remaining

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: