Back to index

plone3  3.1.7
exportimport.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """OFSP export / import support.
00014 
00015 $Id: exportimport.py 71199 2006-11-20 11:03:29Z yuppie $
00016 """
00017 
00018 from zope.component import adapts
00019 
00020 from Products.GenericSetup.interfaces import ISetupEnviron
00021 from Products.GenericSetup.utils import XMLAdapterBase
00022 from Products.GenericSetup.utils import ObjectManagerHelpers
00023 from Products.GenericSetup.utils import PropertyManagerHelpers
00024 
00025 from OFS.interfaces import IFolder
00026 
00027 
00028 class FolderXMLAdapter(XMLAdapterBase, ObjectManagerHelpers,
00029                        PropertyManagerHelpers):
00030 
00031     """XML im- and exporter for Folder.
00032     """
00033 
00034     adapts(IFolder, ISetupEnviron)
00035 
00036     _LOGGER_ID = 'ofs'
00037 
00038     def _exportNode(self):
00039         """Export the object as a DOM node.
00040         """
00041         node = self._getObjectNode('object')
00042         node.appendChild(self._extractProperties())
00043         node.appendChild(self._extractObjects())
00044 
00045         self._logger.info('Folder exported.')
00046         return node
00047 
00048     def _importNode(self, node):
00049         """Import the object from the DOM node.
00050         """
00051         if self.environ.shouldPurge():
00052             self._purgeProperties()
00053             self._purgeObjects()
00054 
00055         self._initProperties(node)
00056         self._initObjects(node)
00057 
00058         self._logger.info('Folder imported.')
00059 
00060     def _exportBody(self):
00061         """Export the object as a file body.
00062         """
00063         if not self.context.meta_type in ('Folder', 'Folder (Ordered)'):
00064             return None
00065 
00066         return XMLAdapterBase._exportBody(self)
00067 
00068     body = property(_exportBody, XMLAdapterBase._importBody)