--- ECHO_content/ECHO_collection.py 2012/01/17 18:39:07 1.310.2.4 +++ ECHO_content/ECHO_collection.py 2012/01/18 16:57:00 1.310.2.5 @@ -36,6 +36,7 @@ from Globals import Persistent, package_ from Acquisition import Implicit from Products.ZCatalog.CatalogPathAwareness import CatalogAware from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon +from Acquisition import aq_parent try: from Products.MetaDataProvider.MetaDataClient import MetaDataClient except: @@ -693,6 +694,8 @@ class ECHO_collection(CatalogAware, Fold meta_type='ECHO_collection' default_catalog='resourceCatalog' + rootMetaTypes = ['ECHO_root', 'ECHO_main', 'ECHO_nav'] + # viewClassificationList=viewClassificationListMaster displayTypes=displayTypes @@ -705,12 +708,11 @@ class ECHO_collection(CatalogAware, Fold return crumbs[0][2].getId() p = self - sec = None # descend parents to the root (and remember the last id) - while p is not None and p.meta_type != 'ECHO_root' and p.meta_type!='ECHO_main' and p.meta_type!='ECHO_nav': + while p is not None and p.meta_type not in self.rootMetaTypes: sec = p.getId() - p = p.aq_parent + p = aq_parent(p.context) return sec @@ -724,13 +726,32 @@ class ECHO_collection(CatalogAware, Fold sec = None subsec = None # descend parents to the root (and remember the last id) - while p is not None and p.meta_type != 'ECHO_root' and p.meta_type!='ECHO_main' and p.meta_type!='ECHO_nav': + while p is not None and p.meta_type not in self.rootMetaTypes: subsec = sec sec = p.getId() - p = p.aq_parent + p = aq_parent(p.context) return subsec + def getHierCrumbs(self): + """returns a list of hierarchical breadcrumbs from self to the ECHO_root""" + # crumb for this object + crumb = {'obj': self, + 'url': self.absolute_url(), + 'label': self.getLabel()} + crumbs = [crumb] + # call the parent's method recursively + parent = aq_parent(self) + if hasattr(parent, 'getHierCrumbs'): + if self.title: + return parent.getHierCrumbs() + crumbs + else: + # if there's no title, skip this level + return parent.getHierCrumbs() + + return crumbs + + def exportImportObjects_html(self,RESPONSE): """ImportObject"""