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 """PythonScript 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 BodyAdapterBase
00022 
00023 from interfaces import IPythonScript
00024 
00025 
00026 class PythonScriptBodyAdapter(BodyAdapterBase):
00027 
00028     """Body im- and exporter for PythonScript.
00029     """
00030 
00031     adapts(IPythonScript, ISetupEnviron)
00032 
00033     def _exportBody(self):
00034         """Export the object as a file body.
00035         """
00036         return self.context.read()
00037 
00038     def _importBody(self, body):
00039         """Import the object from the file body.
00040         """
00041         self.context.write(body)
00042 
00043     body = property(_exportBody, _importBody)
00044 
00045     mime_type = 'text/plain'
00046 
00047     suffix = '.py'