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
This commit is contained in:
parent
9dec6887b6
commit
8e8797a4d1
3 changed files with 25 additions and 5 deletions
21
external/annotation.py
vendored
21
external/annotation.py
vendored
|
@ -23,6 +23,7 @@ $Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
|
from zope.dublincore.interfaces import IZopeDublinCore
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
|
|
||||||
from loops.external.element import Element, elementTypes
|
from loops.external.element import Element, elementTypes
|
||||||
|
@ -47,8 +48,26 @@ class AnnotationsExtractor(object):
|
||||||
implements(ISubExtractor)
|
implements(ISubExtractor)
|
||||||
adapts(ILoopsObject)
|
adapts(ILoopsObject)
|
||||||
|
|
||||||
|
dcAttributes = ('title', 'description', 'creators', 'created', 'modified')
|
||||||
|
|
||||||
|
def __init__(self, context):
|
||||||
|
self.context = context
|
||||||
|
|
||||||
def extract(self):
|
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(
|
elementTypes.update(dict(
|
||||||
|
|
2
external/base.py
vendored
2
external/base.py
vendored
|
@ -176,7 +176,7 @@ class Extractor(Base):
|
||||||
yield elem
|
yield elem
|
||||||
childPath = path and '/'.join((path, name)) or name
|
childPath = path and '/'.join((path, name)) or name
|
||||||
for elem in self.extractNodes(obj, childPath):
|
for elem in self.extractNodes(obj, childPath):
|
||||||
self.provideSubElements(obj, elem)
|
#self.provideSubElements(obj, elem)
|
||||||
yield elem
|
yield elem
|
||||||
|
|
||||||
# helper methods
|
# helper methods
|
||||||
|
|
7
external/configure.zcml
vendored
7
external/configure.zcml
vendored
|
@ -9,17 +9,18 @@
|
||||||
|
|
||||||
<zope:utility factory="loops.external.pyfunc.PyWriter" />
|
<zope:utility factory="loops.external.pyfunc.PyWriter" />
|
||||||
|
|
||||||
|
<zope:adapter factory="loops.external.annotation.AnnotationsExtractor" />
|
||||||
|
|
||||||
|
<!-- views -->
|
||||||
|
|
||||||
<browser:pages for="loops.interfaces.ILoops"
|
<browser:pages for="loops.interfaces.ILoops"
|
||||||
class="loops.external.browser.ExportImport"
|
class="loops.external.browser.ExportImport"
|
||||||
permission="zope.ManageSite">
|
permission="zope.ManageSite">
|
||||||
|
|
||||||
<browser:page name="exportimport.html"
|
<browser:page name="exportimport.html"
|
||||||
template="exportimport.pt"
|
template="exportimport.pt"
|
||||||
menu="zmi_views" title="Export/Import" />
|
menu="zmi_views" title="Export/Import" />
|
||||||
|
|
||||||
<browser:page name="export_loops.html"
|
<browser:page name="export_loops.html"
|
||||||
attribute="export" />
|
attribute="export" />
|
||||||
|
|
||||||
</browser:pages>
|
</browser:pages>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
Loading…
Add table
Reference in a new issue