tolerate None values in title and description

This commit is contained in:
Helmut Merz 2011-10-20 17:48:59 +02:00
parent 6d5f273f28
commit 9f5133152f
4 changed files with 5 additions and 3 deletions

View file

@ -422,6 +422,8 @@ class BaseView(GenericView, I18NView):
def renderDescription(self, text=None):
if text is None:
text = self.description
if text is None:
return u''
htmlPattern = re.compile(r'<(.+)>.+</\1>')
if htmlPattern.search(text):
return text

View file

@ -368,7 +368,7 @@ class ConceptView(BaseView):
def parents(self):
rels = sorted(self.context.getParentRelations(),
key=(lambda x: x.first.title.lower()))
key=(lambda x: x.first.title and x.first.title.lower()))
for r in rels:
yield self.childViewFactory(r, self.request)

View file

@ -201,7 +201,7 @@ class Concept(Contained, Persistent):
relationships = [ConceptRelation(None, self, p) for p in predicates]
if sort == 'default':
#sort = lambda x: (x.order, x.first.title.lower())
sort = lambda x: (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)
if canListObject(r.first, noSecurityCheck))
return sorted(rels, key=sort)

View file

@ -249,7 +249,7 @@ class Search(BaseView):
result = [r for r in result if self.checkStates(r)]
fv = FilterView(self.context, self.request)
result = fv.apply(result)
result = sorted(result, key=lambda x: x.title.lower())
result = sorted(result, key=lambda x: x.title and x.title.lower())
return self.viewIterator(result)
def checkStates(self, obj):