Back to index

plone3  3.1.7
Upgrade.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 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 """
00014     Utility functions for upgrading CMFDefault-based sites.
00015 """
00016 
00017 from Acquisition import aq_inner
00018 
00019 
00020 def upgrade_decor_skins( self ):
00021     """
00022         Upgrade old skin diretories loaded from 'CMFDecor' to load from
00023         'CMFDefault' (and zap the 'zpt_images' one).
00024     """
00025     log = []
00026 
00027     DELETED_SKINS = ( 'zpt_images' , )
00028 
00029     MOVED_SKINS = ( 'zpt_content'
00030                   , 'zpt_control'
00031                   , 'zpt_generic'
00032                   )
00033 
00034     skins_tool = aq_inner( self ).portal_skins # start from CMFSite!
00035 
00036     for deleted in DELETED_SKINS:
00037 
00038         try:
00039 
00040             skins_tool._delObject( deleted )
00041 
00042         except AttributeError:
00043             pass
00044 
00045         else:
00046             log.append( 'Deleted CMFDecor skin directory: %s' % deleted )
00047 
00048     for moved in MOVED_SKINS:
00049 
00050         skin_dir = getattr( skins_tool, moved, None )
00051 
00052         if skin_dir is not None:
00053 
00054             skin_dir.manage_properties(
00055                 dirpath='Products/CMFDefault/skins/%s' % moved )
00056             log.append( 'Updated CMFDecor skin directory to CMFDefault: %s'
00057                       % moved )
00058 
00059     return '\n'.join(log)