Back to index

plone3  3.1.7
memberdata_properties.py
Go to the documentation of this file.
00001 """MemberData tool properties setup handlers.
00002 
00003 $Id:$
00004 """
00005 
00006 from zope.app import zapi
00007 from Products.CMFCore.utils import getToolByName
00008 from Products.GenericSetup.interfaces import IBody
00009 
00010 _FILENAME = 'memberdata_properties.xml'
00011 
00012 def importMemberDataProperties(context):
00013     """ Import MemberData tool properties.
00014     """
00015     site = context.getSite()
00016     logger = context.getLogger('memberdata')
00017     ptool = getToolByName(site, 'portal_memberdata')
00018 
00019     body = context.readDataFile(_FILENAME)
00020     if body is None:
00021         logger.info('Nothing to import.')
00022         return
00023 
00024     importer = zapi.queryMultiAdapter((ptool, context), IBody)
00025     if importer is None:
00026         logger.warning('Import adapter missing.')
00027         return
00028 
00029     importer.body = body
00030     logger.info('MemberData tool imported.')
00031 
00032 def exportMemberDataProperties(context):
00033     """ Export MemberData tool properties .
00034     """
00035     site = context.getSite()
00036     logger = context.getLogger('memberdata')
00037     ptool = getToolByName(site, 'portal_memberdata', None)
00038     if ptool is None:
00039         logger.info('Nothing to export.')
00040         return
00041 
00042     exporter = zapi.queryMultiAdapter((ptool, context), IBody)
00043     if exporter is None:
00044         logger.warning('Export adapter missing.')
00045         return
00046 
00047     context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
00048     logger.info('MemberData tool exported.')
00049