tolerate missing title when sorting

This commit is contained in:
Helmut Merz 2011-11-21 14:52:46 +01:00
parent 02e07c0e85
commit bd13c779b6

View file

@ -186,7 +186,7 @@ class Concept(Contained, Persistent):
predicates = predicates is None and ['*'] or predicates predicates = predicates is None and ['*'] or predicates
relationships = [ConceptRelation(self, None, p) for p in predicates] relationships = [ConceptRelation(self, None, p) for p in predicates]
if sort == 'default': if sort == 'default':
sort = lambda x: (x.order, x.second.title.lower()) sort = lambda x: (x.order, (x.second.title and x.second.title.lower()))
rels = (r for r in getRelations(self, child, relationships=relationships) rels = (r for r in getRelations(self, child, relationships=relationships)
if canListObject(r.second, noSecurityCheck)) if canListObject(r.second, noSecurityCheck))
return sorted(rels, key=sort) return sorted(rels, key=sort)
@ -200,7 +200,6 @@ class Concept(Contained, Persistent):
predicates = predicates is None and ['*'] or predicates predicates = predicates is None and ['*'] or predicates
relationships = [ConceptRelation(None, self, p) for p in predicates] relationships = [ConceptRelation(None, self, p) for p in predicates]
if sort == 'default': if sort == 'default':
#sort = lambda x: (x.order, x.first.title.lower())
sort = lambda x: (x.first.title and x.first.title.lower()) sort = lambda x: (x.first.title and x.first.title.lower())
rels = (r for r in getRelations(parent, self, relationships=relationships) rels = (r for r in getRelations(parent, self, relationships=relationships)
if canListObject(r.first, noSecurityCheck)) if canListObject(r.first, noSecurityCheck))