catch error when indexing a creator that does no longer exist

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3207 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-02-05 18:29:45 +00:00
parent 8ce40311ac
commit 529bdc7c1f

View file

@ -26,7 +26,7 @@ from zope import component, schema
from zope.app.container.btree import BTreeContainer from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import Contained from zope.app.container.contained import Contained
from zope.app.container.interfaces import IAdding from zope.app.container.interfaces import IAdding
from zope.app.security.interfaces import IAuthentication from zope.app.security.interfaces import IAuthentication, PrincipalLookupError
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.component import adapts from zope.component import adapts
from zope.component.interfaces import ObjectEvent from zope.component.interfaces import ObjectEvent
@ -402,15 +402,12 @@ class IndexAttributes(object):
return adapted(self.context) return adapted(self.context)
def text(self): def text(self):
#ctx = self.context # TODO: use IIndexAttributes(self.adapted) if available
#return ' '.join((getName(ctx), ctx.title,))
description = self.context.description description = self.context.description
if isinstance(description, I18NValue): if isinstance(description, I18NValue):
description = ' '.join(description.values()) description = ' '.join(description.values())
#actx = adapted(ctx)
actx = self.adapted actx = self.adapted
indexAttrs = getattr(actx, '_textIndexAttributes', ()) indexAttrs = getattr(actx, '_textIndexAttributes', ())
#return ' '.join([getName(ctx), ctx.title, ctx.description] +
return ' '.join([self.title(), description] + return ' '.join([self.title(), description] +
self.creators() + self.creators() +
[getattr(actx, attr, u'???') for attr in indexAttrs]).strip() [getattr(actx, attr, u'???') for attr in indexAttrs]).strip()
@ -418,12 +415,8 @@ class IndexAttributes(object):
def title(self): def title(self):
context = self.context context = self.context
title = context.title title = context.title
#description = context.description
if isinstance(title, I18NValue): if isinstance(title, I18NValue):
title = ' '.join(title.values()) title = ' '.join(title.values())
#if isinstance(description, I18NValue):
# description = ' '.join(description.values())
#return ' '.join((getName(context), title, description)).strip()
return ' '.join((getName(context), title)).strip() return ' '.join((getName(context), title)).strip()
def creators(self): def creators(self):
@ -431,9 +424,11 @@ class IndexAttributes(object):
pau = component.getUtility(IAuthentication) pau = component.getUtility(IAuthentication)
creators = [] creators = []
for c in cr: for c in cr:
principal = pau.getPrincipal(c) try:
if principal is not None: principal = pau.getPrincipal(c)
creators.append(principal.title) creators.append(principal.title)
except PrincipalLookupError:
creators.append(c)
return creators return creators
def identifier(self): def identifier(self):