Mercurial > hg > MPIWGWeb
diff MPIWGRoot.py @ 13:325e7c338815
research websites page. better department editing.
author | casties |
---|---|
date | Mon, 04 Mar 2013 18:18:28 +0100 |
parents | c711fe75d0ac |
children | 69d221c3e010 |
line wrap: on
line diff
--- a/MPIWGRoot.py Fri Mar 01 17:57:36 2013 +0100 +++ b/MPIWGRoot.py Mon Mar 04 18:18:28 2013 +0100 @@ -258,11 +258,9 @@ def getSections(self): """returns a list of all sections i.e. top-level MPIWGFolders""" - secs = self.objectItems(['MPIWGFolder']) - secs.sort(sortWeight) - #logging.debug("root: %s secs: %s"%(repr(self.absolute_url()), repr(secs))) - # return pure list of objects - return [s[1] for s in secs] + items = self.objectValues(spec='MPIWGFolder')[:] + items.sort(key=lambda x:getattr(x, 'weight', '0')) + return items def getSectionStyle(self, name, style=""): """returns a string with the given style + '-sel' if the current section == name""" @@ -273,14 +271,16 @@ def getFeatures(self, num=None): """returns a list of the last num Features""" - dir = getattr(self, 'features') - features = dir.objectItems(['MPIWGFeature']) - features.sort(sortWeight) + dir = getattr(self, 'features', None) + if dir is None: + return [] + + items = dir.objectValues(spec='MPIWGFeature')[:] + items.sort(key=lambda x:getattr(x, 'weight', '0')) if num is not None: # take only the last num elements - features = features[-num:] - # return pure list of objects - return [f[1] for f in features] + items = items[-num:] + return items def getDepartments(self): """returns a list of the Departments""" @@ -288,10 +288,9 @@ if dir is None: return [] - depts = dir.objectItems(['MPIWGDepartment']) - depts.sort(sortWeight) - # return pure list of objects - return [f[1] for f in depts] + items = dir.objectValues(spec='MPIWGDepartment')[:] + items.sort(key=lambda x:getattr(x, 'weight', '0')) + return items def getMPIWGRoot(self): """returns the MPIWG root""" @@ -301,6 +300,7 @@ """returns the URL to the root""" return self.absolute_url() + #WTF? def patchProjects(self,RESPONSE): """patch""" projects=self.ZopeFind(self.projects,obj_metatypes=['MPIWGProject'])