Back to index

plone3  3.1.7
Functions
ATContentTypes.migration.v1_2 Namespace Reference

Functions

def upgradeATCTTool

Detailed Description

Migration functions for ATContentTypes 1.2. These are called during the
   usual CMFPlone migration.

Function Documentation

def ATContentTypes.migration.v1_2.upgradeATCTTool (   portal,
  out 
)

Definition at line 12 of file __init__.py.

00012 
00013 def upgradeATCTTool(portal, out):
00014     tool = getToolByName(portal, TOOLNAME, None)
00015     if not hasattr(aq_base(tool), '_version'):
00016         # the tool already has been upgraded
00017         return
00018     # First we get all relevant old configuration and make sure we get
00019     # real copies of the various objects
00020     old_conf = {}
00021     old_conf['album_batch_size'] = int(getattr(tool, 'album_batch_size', 30))
00022     old_conf['album_image_scale'] = str(getattr(tool, 'album_image_scale', 'thumb'))
00023     old_conf['image_types'] = list(getattr(tool, 'image_types', ['Image', 'News Item']))
00024     old_conf['folder_types'] = list(getattr(tool, 'folder_types', ['Image']))
00025     old_conf['single_image_scale'] = str(getattr(tool, 'single_image_scale', 'preview'))
00026     old_conf['topic_indexes'] = tool.topic_indexes.copy()
00027     old_conf['topic_metadata'] = tool.topic_metadata.copy()
00028     old_conf['allowed_portal_types'] = tuple(tool.allowed_portal_types)
00029     
00030     # Remove the old tool completely
00031     del(tool)
00032     portal._delObject(TOOLNAME)
00033     transaction.savepoint(optimistic=True)
00034     
00035     # Create new tool
00036     portal._setObject(TOOLNAME, ATCTTool())
00037     tool = portal.get(TOOLNAME)
00038     # And apply the configuration again
00039     tool._setPropValue('album_batch_size', old_conf['album_batch_size'])
00040     tool._setPropValue('album_image_scale', old_conf['album_image_scale'])
00041     tool._setPropValue('image_types', tuple(old_conf['image_types']))
00042     tool._setPropValue('folder_types', tuple(old_conf['folder_types']))
00043     tool._setPropValue('single_image_scale', old_conf['single_image_scale'])
00044     tool._setPropValue('allowed_portal_types', old_conf['allowed_portal_types'])
00045 
00046     # XXX Index and metadata should be updated instead of being reapplied
00047     tool._setPropValue('topic_indexes', old_conf['topic_indexes'])
00048     tool._setPropValue('topic_metadata', old_conf['topic_metadata'])
00049 
00050     transaction.savepoint(optimistic=True)
00051     
00052     out.append('Upgraded the ATContentTypes tool.')

Here is the call graph for this function:

Here is the caller graph for this function: