--- ECHO_content/ECHO_helpers.py 2012/01/17 18:39:07 1.103.2.3 +++ ECHO_content/ECHO_helpers.py 2012/01/19 19:03:28 1.103.2.4 @@ -11,6 +11,7 @@ from OFS.SimpleItem import SimpleItem from Globals import package_home import Globals from AccessControl import ClassSecurityInfo +from Acquisition import aq_parent,aq_chain,aq_base import os.path from OFS.Folder import Folder import ECHO_collection @@ -694,6 +695,41 @@ def checkOnlyOneInGroup(object): else: return object + +def getCrumb(self): + """returns breadcrumb for this object""" + # ignore this object if title is empty + if not self.title: + return None + + crumb = {'obj': self, + 'url': self.absolute_url(), + 'label': self.getLabel()} + return crumb + +# roots of the ECHO hierarchy +rootMetaTypes = ['ECHO_root', 'ECHO_main', 'ECHO_nav'] + +def getHierCrumbs(self): + """returns a list of hierarchical breadcrumbs from self to the ECHO_root""" + crumbs = [] + # walk the acquisition chain + for obj in aq_chain(self): + #logging.debug("getHiercrumbs: obj=%s"%(obj)) + # test if the object really has a getCrumb method + if hasattr(aq_base(obj), 'getCrumb'): + crumb = obj.getCrumb() + #logging.debug("getHiercrumbs: got %s from %s"%(crumb,obj)) + if crumb is not None: + crumbs.insert(0, crumb) + + if obj.meta_type in rootMetaTypes: + # stop when we reach the ECHO root + return crumbs + + return crumbs + + def getSubCols(self, sortfield=None, subColTypes=displayTypes, sortFieldMD=None,