tolerate None values in title and description
This commit is contained in:
		
							parent
							
								
									6d5f273f28
								
							
						
					
					
						commit
						9f5133152f
					
				
					 4 changed files with 5 additions and 3 deletions
				
			
		|  | @ -422,6 +422,8 @@ class BaseView(GenericView, I18NView): | ||||||
|     def renderDescription(self, text=None): |     def renderDescription(self, text=None): | ||||||
|         if text is None: |         if text is None: | ||||||
|             text = self.description |             text = self.description | ||||||
|  |         if text is None: | ||||||
|  |             return u'' | ||||||
|         htmlPattern = re.compile(r'<(.+)>.+</\1>') |         htmlPattern = re.compile(r'<(.+)>.+</\1>') | ||||||
|         if htmlPattern.search(text): |         if htmlPattern.search(text): | ||||||
|             return text |             return text | ||||||
|  |  | ||||||
|  | @ -368,7 +368,7 @@ class ConceptView(BaseView): | ||||||
| 
 | 
 | ||||||
|     def parents(self): |     def parents(self): | ||||||
|         rels = sorted(self.context.getParentRelations(), |         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: |         for r in rels: | ||||||
|             yield self.childViewFactory(r, self.request) |             yield self.childViewFactory(r, self.request) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -201,7 +201,7 @@ class Concept(Contained, Persistent): | ||||||
|         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.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) |         rels = (r for r in getRelations(parent, self, relationships=relationships) | ||||||
|                   if canListObject(r.first, noSecurityCheck)) |                   if canListObject(r.first, noSecurityCheck)) | ||||||
|         return sorted(rels, key=sort) |         return sorted(rels, key=sort) | ||||||
|  |  | ||||||
|  | @ -249,7 +249,7 @@ class Search(BaseView): | ||||||
|         result = [r for r in result if self.checkStates(r)] |         result = [r for r in result if self.checkStates(r)] | ||||||
|         fv = FilterView(self.context, self.request) |         fv = FilterView(self.context, self.request) | ||||||
|         result = fv.apply(result) |         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) |         return self.viewIterator(result) | ||||||
| 
 | 
 | ||||||
|     def checkStates(self, obj): |     def checkStates(self, obj): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue