Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFPlone.browser.navtree.NavtreeQueryBuilder Class Reference
Inheritance diagram for CMFPlone.browser.navtree.NavtreeQueryBuilder:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 query

Detailed Description

Build a navtree query based on the settings in navtree_properties

Definition at line 35 of file navtree.py.


Constructor & Destructor Documentation

Reimplemented in CMFPlone.browser.navtree.SitemapQueryBuilder.

Definition at line 40 of file navtree.py.

00040 
00041     def __init__(self, context):
00042         portal_properties = getToolByName(context, 'portal_properties')
00043         portal_url = getToolByName(context, 'portal_url')
00044         navtree_properties = getattr(portal_properties, 'navtree_properties')
00045 
00046         # Acquire a custom nav query if available
00047         customQuery = getattr(context, 'getCustomNavQuery', None)
00048         if customQuery is not None and utils.safe_callable(customQuery):
00049             query = customQuery()
00050         else:
00051             query = {}
00052 
00053         # Construct the path query
00054 
00055         rootPath = getNavigationRoot(context)
00056         currentPath = '/'.join(context.getPhysicalPath())
00057 
00058         # If we are above the navigation root, a navtree query would return
00059         # nothing (since we explicitly start from the root always). Hence,
00060         # use a regular depth-1 query in this case.
00061 
00062         if not currentPath.startswith(rootPath):
00063             query['path'] = {'query' : rootPath, 'depth' : 1}
00064         else:
00065             query['path'] = {'query' : currentPath, 'navtree' : 1}
00066 
00067         topLevel = navtree_properties.getProperty('topLevel', 0)
00068         if topLevel and topLevel > 0:
00069              query['path']['navtree_start'] = topLevel + 1
00070 
00071         # XXX: It'd make sense to use 'depth' for bottomLevel, but it doesn't
00072         # seem to work with EPI.
00073 
00074         # Only list the applicable types
00075         query['portal_type'] = utils.typesToList(context)
00076 
00077         # Apply the desired sort
00078         sortAttribute = navtree_properties.getProperty('sortAttribute', None)
00079         if sortAttribute is not None:
00080             query['sort_on'] = sortAttribute
00081             sortOrder = navtree_properties.getProperty('sortOrder', None)
00082             if sortOrder is not None:
00083                 query['sort_order'] = sortOrder
00084 
00085         # Filter on workflow states, if enabled
00086         if navtree_properties.getProperty('enable_wf_state_filtering', False):
00087             query['review_state'] = navtree_properties.getProperty('wf_states_to_show', ())
00088 
00089         self.query = query

Here is the call graph for this function:


Member Function Documentation

Definition at line 90 of file navtree.py.

00090 
00091     def __call__(self):
00092         return self.query

Here is the caller graph for this function:


Member Data Documentation

Definition at line 88 of file navtree.py.


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