From 3589363264cbc794518e71f7f05bbe12a08a8570 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sat, 7 Feb 2009 16:28:07 +0000 Subject: [PATCH] use IIndexAttributes adapter (if available) based on adapted object for text index on concept git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3215 fd906abe-77d9-0310-91a1-e0d9ade77398 --- concept.py | 18 +++++++++++++++--- configure.zcml | 5 +++++ resource.py | 29 ++++++++++++++++++++++++++++- tests/setup.py | 2 ++ versioning/testsetup.py | 12 ++++++++++++ 5 files changed, 62 insertions(+), 4 deletions(-) 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" /> + +