From 2c512a1ff7941ae621564ec6db070b546d262a08 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 10 Oct 2015 11:46:54 +0200 Subject: [PATCH] make indexing more fault-tolerant --- concept.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/concept.py b/concept.py index a8ed614..2d1878d 100644 --- a/concept.py +++ b/concept.py @@ -45,7 +45,7 @@ from cybertools.typology.interfaces import IType, ITypeManager from cybertools.util.jeep import Jeep from loops.base import ParentInfo -from loops.common import adapted, AdapterBase +from loops.common import adapted, baseObject, AdapterBase from loops.i18n.common import I18NValue from loops.interfaces import IConcept, IConceptRelation, IConceptView from loops.interfaces import IResource @@ -459,7 +459,10 @@ class IndexAttributes(object): #if self.adapted != self.context: if isinstance(self.adapted, AdapterBase): #return component.queryAdapter(self.adapted, IIndexAttributes) - return IIndexAttributes(self.adapted, None) + iattr = IIndexAttributes(self.adapted, None) + if iattr.__class__ == self.__class__: + return None + return iattr def text(self): if self.adaptedIndexAttributes is not None: @@ -483,14 +486,14 @@ class IndexAttributes(object): title = u'' if isinstance(title, I18NValue): title = ' '.join(title.values()) - return ' '.join((getName(context), title)).strip() + return ' '.join((getName(baseObject(context)), title)).strip() def date(self): if self.adaptedIndexAttributes is not None: return self.adaptedIndexAttributes.date() def creators(self): - cr = IZopeDublinCore(self.context).creators or [] + cr = IZopeDublinCore(baseObject(self.context)).creators or [] pau = component.getUtility(IAuthentication) creators = [] for c in cr: @@ -507,7 +510,7 @@ class IndexAttributes(object): def identifier(self): id = getattr(self.adapted, 'identifier', None) if id is None: - return getName(self.context) + return getName(baseObject(self.context)) return id def keywords(self):