Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.app.portlets.portlets.navigation.QueryBuilder Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 context
 portlet
 query

Detailed Description

Build a navtree query based on the settings in navtree_properties
and those set on the portlet.

Definition at line 231 of file navigation.py.


Constructor & Destructor Documentation

def plone.app.portlets.portlets.navigation.QueryBuilder.__init__ (   self,
  context,
  portlet 
)

Definition at line 238 of file navigation.py.

00238 
00239     def __init__(self, context, portlet):
00240         self.context = context
00241         self.portlet = portlet
00242         
00243         portal_properties = getToolByName(context, 'portal_properties')
00244         navtree_properties = getattr(portal_properties, 'navtree_properties')
00245         
00246         portal_url = getToolByName(context, 'portal_url')
00247         
00248         # Acquire a custom nav query if available
00249         customQuery = getattr(context, 'getCustomNavQuery', None)
00250         if customQuery is not None and utils.safe_callable(customQuery):
00251             query = customQuery()
00252         else:
00253             query = {}
00254 
00255         # Construct the path query
00256 
00257         rootPath = getNavigationRoot(context, relativeRoot=portlet.root)
00258         currentPath = '/'.join(context.getPhysicalPath())
00259 
00260         # If we are above the navigation root, a navtree query would return
00261         # nothing (since we explicitly start from the root always). Hence,
00262         # use a regular depth-1 query in this case.
00263 
00264         if not currentPath.startswith(rootPath):
00265             query['path'] = {'query' : rootPath, 'depth' : 1}
00266         else:
00267             query['path'] = {'query' : currentPath, 'navtree' : 1}
00268 
00269         topLevel = portlet.topLevel or navtree_properties.getProperty('topLevel', 0)
00270         if topLevel and topLevel > 0:
00271              query['path']['navtree_start'] = topLevel + 1
00272 
00273         # XXX: It'd make sense to use 'depth' for bottomLevel, but it doesn't
00274         # seem to work with EPI.
00275 
00276         # Only list the applicable types
00277         query['portal_type'] = utils.typesToList(context)
00278 
00279         # Apply the desired sort
00280         sortAttribute = navtree_properties.getProperty('sortAttribute', None)
00281         if sortAttribute is not None:
00282             query['sort_on'] = sortAttribute
00283             sortOrder = navtree_properties.getProperty('sortOrder', None)
00284             if sortOrder is not None:
00285                 query['sort_order'] = sortOrder
00286 
00287         # Filter on workflow states, if enabled
00288         if navtree_properties.getProperty('enable_wf_state_filtering', False):
00289             query['review_state'] = navtree_properties.getProperty('wf_states_to_show', ())
00290 
00291         self.query = query

Here is the caller graph for this function:


Member Function Documentation

Definition at line 292 of file navigation.py.

00292 
00293     def __call__(self):
00294         return self.query
        

Here is the caller graph for this function:


Member Data Documentation

Definition at line 239 of file navigation.py.

Definition at line 240 of file navigation.py.

Definition at line 290 of file navigation.py.


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