diff --git a/concept.py b/concept.py index 89c7513..97ad540 100644 --- a/concept.py +++ b/concept.py @@ -401,16 +401,24 @@ class IndexAttributes(object): def adapted(self): return adapted(self.context) + @Lazy + def adaptedIndexAttributes(self): + if self.adapted != self.context: + return component.queryAdapter(self.adapted, IIndexAttributes) + return IIndexAttributes(self.adapted, None) + def text(self): - # TODO: use IIndexAttributes(self.adapted) if available + if self.adaptedIndexAttributes is not None: + return self.adaptedIndexAttributes.text() description = self.context.description if isinstance(description, I18NValue): description = ' '.join(description.values()) actx = self.adapted indexAttrs = getattr(actx, '_textIndexAttributes', ()) + indexValues = [getattr(actx, attr, u'???') for attr in indexAttrs] return ' '.join([self.title(), description] + - self.creators() + - [getattr(actx, attr, u'???') for attr in indexAttrs]).strip() + [c for c in self.creators() if c is not None] + + [v for v in indexValues if v is not None]).strip() def title(self): context = self.context @@ -419,6 +427,10 @@ class IndexAttributes(object): title = ' '.join(title.values()) return ' '.join((getName(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 [] pau = component.getUtility(IAuthentication) diff --git a/configure.zcml b/configure.zcml index 3f9f9b2..6763165 100644 --- a/configure.zcml +++ b/configure.zcml @@ -387,6 +387,11 @@ name="text/rtf" factory="cybertools.text.rtf.RtfTransform" /> + +