make indexing more fault-tolerant

This commit is contained in:
Helmut Merz 2015-10-10 11:46:54 +02:00
parent f64b60f3b5
commit 2c512a1ff7

View file

@ -45,7 +45,7 @@ from cybertools.typology.interfaces import IType, ITypeManager
from cybertools.util.jeep import Jeep from cybertools.util.jeep import Jeep
from loops.base import ParentInfo 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.i18n.common import I18NValue
from loops.interfaces import IConcept, IConceptRelation, IConceptView from loops.interfaces import IConcept, IConceptRelation, IConceptView
from loops.interfaces import IResource from loops.interfaces import IResource
@ -459,7 +459,10 @@ class IndexAttributes(object):
#if self.adapted != self.context: #if self.adapted != self.context:
if isinstance(self.adapted, AdapterBase): if isinstance(self.adapted, AdapterBase):
#return component.queryAdapter(self.adapted, IIndexAttributes) #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): def text(self):
if self.adaptedIndexAttributes is not None: if self.adaptedIndexAttributes is not None:
@ -483,14 +486,14 @@ class IndexAttributes(object):
title = u'' title = u''
if isinstance(title, I18NValue): if isinstance(title, I18NValue):
title = ' '.join(title.values()) title = ' '.join(title.values())
return ' '.join((getName(context), title)).strip() return ' '.join((getName(baseObject(context)), title)).strip()
def date(self): def date(self):
if self.adaptedIndexAttributes is not None: if self.adaptedIndexAttributes is not None:
return self.adaptedIndexAttributes.date() return self.adaptedIndexAttributes.date()
def creators(self): def creators(self):
cr = IZopeDublinCore(self.context).creators or [] cr = IZopeDublinCore(baseObject(self.context)).creators or []
pau = component.getUtility(IAuthentication) pau = component.getUtility(IAuthentication)
creators = [] creators = []
for c in cr: for c in cr:
@ -507,7 +510,7 @@ class IndexAttributes(object):
def identifier(self): def identifier(self):
id = getattr(self.adapted, 'identifier', None) id = getattr(self.adapted, 'identifier', None)
if id is None: if id is None:
return getName(self.context) return getName(baseObject(self.context))
return id return id
def keywords(self): def keywords(self):