products/CPSRSS

changeset 178:c478d30a9b2f

simplify XML I/O for RSS Channel
author div
date Tue, 24 Jan 2006 16:40:05 +0000
parents 9c93ad333884
children c67b272860fd
files configure.zcml exportimport.py
diffstat 2 files changed, 9 insertions(+), 59 deletions(-) [+]
line diff
     1.1 --- a/configure.zcml
     1.2 +++ b/configure.zcml
     1.3 @@ -1,5 +1,6 @@
     1.4  <configure
     1.5 -    xmlns="http://namespaces.zope.org/zope">
     1.6 +    xmlns="http://namespaces.zope.org/zope"
     1.7 +    xmlns:five="http://namespaces.zope.org/five">
     1.8  
     1.9    <adapter
    1.10        factory=".exportimport.RSSToolXMLAdapter"
    1.11 @@ -15,4 +16,11 @@
    1.12             Products.GenericSetup.interfaces.ISetupEnviron"
    1.13        />
    1.14  
    1.15 +  <five:registerClass
    1.16 +      class=".RSSChannel.RSSChannel"
    1.17 +      meta_type="RSS Channel"
    1.18 +      permission="cmf.ManagePortal"
    1.19 +      global="False"
    1.20 +      />
    1.21 +
    1.22  </configure>
     2.1 --- a/exportimport.py
     2.2 +++ b/exportimport.py
     2.3 @@ -97,9 +97,6 @@
     2.4          self._initProperties(node)
     2.5  
     2.6          obj_id = str(node.getAttribute('name'))
     2.7 -        if not obj_id:
     2.8 -            # BBB: for CMF 1.5 profiles
     2.9 -            obj_id = str(node.getAttribute('id'))
    2.10          self._logger.info('%r rss feed imported.' % obj_id)
    2.11  
    2.12  
    2.13 @@ -136,58 +133,3 @@
    2.14  
    2.15          self._logger.info("RSS tool imported.")
    2.16  
    2.17 -    def _initObjects(self, node):
    2.18 -        """Initialize subobjects from node children.
    2.19 -        """
    2.20 -        for child in node.childNodes:
    2.21 -            if child.nodeName != 'object':
    2.22 -                continue
    2.23 -            if child.hasAttribute('deprecated'):
    2.24 -                continue
    2.25 -            parent = self.context
    2.26 -
    2.27 -            obj_id = str(child.getAttribute('name'))
    2.28 -            if obj_id not in parent.objectIds():
    2.29 -                meta_type = str(child.getAttribute('meta_type'))
    2.30 -                if meta_type != RSSChannel_meta_type:
    2.31 -                    raise ValueError(meta_type)
    2.32 -                ob = RSSChannel(obj_id)
    2.33 -                parent._setObject(obj_id, ob)
    2.34 -                
    2.35 -            if child.hasAttribute('insert-before'):
    2.36 -                insert_before = child.getAttribute('insert-before')
    2.37 -                if insert_before == '*':
    2.38 -                    parent.moveObjectsToTop(obj_id)
    2.39 -                else:
    2.40 -                    try:
    2.41 -                        position = parent.getObjectPosition(insert_before)
    2.42 -                        parent.moveObjectToPosition(obj_id, position)
    2.43 -                    except ValueError:
    2.44 -                        pass
    2.45 -            elif child.hasAttribute('insert-after'):
    2.46 -                insert_after = child.getAttribute('insert-after')
    2.47 -                if insert_after == '*':
    2.48 -                    parent.moveObjectsToBottom(obj_id)
    2.49 -                else:
    2.50 -                    try:
    2.51 -                        position = parent.getObjectPosition(insert_after)
    2.52 -                        parent.moveObjectToPosition(obj_id, position+1)
    2.53 -                    except ValueError:
    2.54 -                        pass
    2.55 -
    2.56 -            obj = getattr(self.context, obj_id)
    2.57 -            importer = zapi.queryMultiAdapter((obj, self.environ), INode)
    2.58 -            if importer:
    2.59 -                importer.node = child
    2.60 -
    2.61 -    def _extractObjects(self):
    2.62 -        fragment = self._doc.createDocumentFragment()
    2.63 -        items = self.context.objectItems()
    2.64 -        items.sort()
    2.65 -        for id, ob in items:
    2.66 -            exporter = zapi.queryMultiAdapter((ob, self.environ), INode)
    2.67 -            if not exporter:
    2.68 -                raise ValueError("RSS Feed %s cannot be adapted to INode" % ob)
    2.69 -            child = exporter._getObjectNode('object', False)
    2.70 -            fragment.appendChild(child)
    2.71 -        return fragment