From 8e8797a4d1dca77dc550fee8fed939c532e64c33 Mon Sep 17 00:00:00 2001 From: helmutm Date: Fri, 28 Mar 2008 13:22:55 +0000 Subject: [PATCH] work in progress: sub-elements, e.g. for annotations and state information - export OK git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2478 fd906abe-77d9-0310-91a1-e0d9ade77398 --- external/annotation.py | 21 ++++++++++++++++++++- external/base.py | 2 +- external/configure.zcml | 7 ++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/external/annotation.py b/external/annotation.py index 49ffc24..2a33531 100644 --- a/external/annotation.py +++ b/external/annotation.py @@ -23,6 +23,7 @@ $Id$ """ from zope.component import adapts +from zope.dublincore.interfaces import IZopeDublinCore from zope.interface import implements from loops.external.element import Element, elementTypes @@ -47,8 +48,26 @@ class AnnotationsExtractor(object): implements(ISubExtractor) adapts(ILoopsObject) + dcAttributes = ('title', 'description', 'creators', 'created', 'modified') + + def __init__(self, context): + self.context = context + def extract(self): - return [] + dc = IZopeDublinCore(self.context, None) + if dc is not None: + result = {} + for attr in self.dcAttributes: + value = getattr(dc, attr, None) + if attr in ('title',): + if value == getattr(self.context, attr): + value = None + if value: + if attr in ('created', 'modified'): + value = value.strftime('%Y-%m-%dT%H:%M') + result[attr] = value + if result: + yield AnnotationsElement(**result) elementTypes.update(dict( diff --git a/external/base.py b/external/base.py index 3be6522..5559884 100644 --- a/external/base.py +++ b/external/base.py @@ -176,7 +176,7 @@ class Extractor(Base): yield elem childPath = path and '/'.join((path, name)) or name for elem in self.extractNodes(obj, childPath): - self.provideSubElements(obj, elem) + #self.provideSubElements(obj, elem) yield elem # helper methods diff --git a/external/configure.zcml b/external/configure.zcml index b7780ef..5fc223c 100644 --- a/external/configure.zcml +++ b/external/configure.zcml @@ -9,17 +9,18 @@ + + + + - - -