# Script that'll migrate from CMF Photo Album to something simpler. You # may have to enable adding of the the Folder content type for # CMF Photo Album / CMF Photo (in portal_types) to make it work. from cStringIO import StringIO def migrate(self): """Migrates all ZPhotoslides containers with images to regular folders with images.""" for path, photo_album in self.ZopeFind(self, obj_metatypes=('Photo Album',), search_sub=1): print path, photo_album convert(photo_album) return "success" def convert(photo_album): if callable(photo_album.id): photo_album_id = photo_album.id() else: photo_album_id = photo_album.id parent = photo_album.getParentNode() if parent.meta_type == 'Photo Album': convert(parent) parent.manage_renameObject(photo_album_id, photo_album_id + '_old') portal_types = parent.portal_types portal_types.constructContent('Folder', parent, photo_album_id, None) new_container = parent[photo_album_id] new_container.update(title=photo_album.title) for image in photo_album.objectValues('Photo'): if callable(image.id): image_id = image.id() else: image_id = image.id new_container.invokeFactory('Image', image_id) new_image = new_container[image_id] new_image.update(title=image.title, image=StringIO(str(image.data))) parent.manage_delObjects(ids=[photo_album_id + '_old'])