Back to index

plone3  3.1.7
mailhost.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 """Mailhost setup handlers.
00014 
00015 $Id: mailhost.py 73035 2007-03-07 16:41:03Z jens $
00016 """
00017 
00018 from Products.MailHost.interfaces import IMailHost
00019 
00020 from zope.component import getSiteManager
00021 
00022 from Products.GenericSetup.utils import exportObjects
00023 from Products.GenericSetup.utils import importObjects
00024 
00025 
00026 def importMailHost(context):
00027     """Import mailhost settings from an XML file.
00028     """
00029     sm = getSiteManager(context.getSite())
00030     tool = sm.getUtility(IMailHost)
00031 
00032     importObjects(tool, '', context)
00033 
00034 def exportMailHost(context):
00035     """Export mailhost settings as an XML file.
00036     """
00037     sm = getSiteManager(context.getSite())
00038     tool = sm.queryUtility(IMailHost)
00039     if tool is None:
00040         logger = context.getLogger('mailhost')
00041         logger.info('Nothing to export.')
00042         return
00043 
00044     exportObjects(tool, '', context)