Back to index

plone3  3.1.7
repository.py
Go to the documentation of this file.
00001 from Products.CMFCore.utils import getToolByName
00002 from Products.CMFEditions.interfaces.IRepository import IRepositoryTool
00003 from Products.GenericSetup.utils import XMLAdapterBase
00004 from Products.GenericSetup.utils import exportObjects
00005 from Products.GenericSetup.utils import importObjects
00006 
00007 
00008 class RepositoryToolXMLAdapter(XMLAdapterBase):
00009     """Mode in- and exporter for RepositoryTool.
00010     """
00011     __used_for__ = IRepositoryTool
00012 
00013     def _exportNode(self):
00014         """Export the object as a DOM node.
00015         """
00016         node=self._doc.createElement('repositorytool')
00017         node.appendChild(self._extractPolicies())
00018 
00019         self._logger.info('RepositoryTool settings exported.')
00020         return node
00021 
00022 
00023     def _importNode(self, node):
00024         if self.environ.shouldPurge():
00025             self._purgePolicies()
00026 
00027         self._initPolicies(node)
00028         self._logger.info('RepositoryTool settings imported.')
00029 
00030 
00031     def _purgePolicies(self):
00032         # XXX
00033         pass
00034 
00035 
00036     def _initPolicies(self, node):
00037         for child in node.childNodes:
00038             if child.nodeName=='policies':
00039                 # XXX
00040                 pass
00041 
00042     def _extractPolicies(self):
00043         node=self._doc.createElement('policies')
00044         # XXX
00045         return node
00046 
00047 
00048 def importRepositoryTool(context):
00049     """Import Repository Tool configuration.
00050     """
00051     site = context.getSite()
00052     tool = getToolByName(site, 'portal_repository')
00053 
00054     importObjects(tool, '', context)
00055 
00056 
00057 def exportRepositoryTool(context):
00058     """Export Repository Tool configuration.
00059     """
00060     site = context.getSite()
00061     tool = getToolByName(site, 'portal_repository', None)
00062     if tool is None:
00063         logger = context.getLogger("repositorytool")
00064         logger.info("Nothing to export.")
00065         return
00066 
00067     exportObjects(tool, '', context)