Migrating from the (now deprecated) ATImage custom content type

We had a whole collection of Plone 3 sites with a custom image type subclass from ATImage. This allowed us to add additional image scaling to the standard list ("logo": (454, 58) "used by our theme pack).

While this works in Plone 4, now this is not the right approach, plone.app.imaging is part of the standard toolkit. It can define custom scales on fly.

It looks like I can enable plone.app.imaging for any type of subclass from ATImage by simply setting “sizes = No” to collect custom scales by type. However, I was left with a redundant subclass of ATImage. Looking at the long term, it would be useful to replace all of our existing “FalconImage” content elements (hundreds in total) with standard “Image” content elements.

A brief experiment on a test site shows that if I just go through a document tree that updates the portal_type attribute from "FalconImage" to "Image", then the content behaves like "Image": each object suddenly acquires Transform and all scales defined using the panel control @@ imaging-controlpanel.

I am sure that there will be consequences of such an approach of brute force. Is there a recommended approach for converting one type to another?

(I'm glad to add a source for our custom ATImage type if someone thinks this is relevant. This is really a very minimal setup for ATImage, with a different collection of sizes on ImageField)

+4
source share
3 answers

Yes, there is a recommended approach:

http://pypi.python.org/pypi/Products.contentmigration

The only thing you need to do is write a custom migration from FalconImage to Image.

Bye, Giacomo

+2
source

You need to use Products.contentmigration , but the docs have no place to run. Use the docs on plone.org to step through the content.

+1
source

Thanks to Giacomo and Ross for the pointers.

Just in case, this is useful for others, my transition code looked like this:

 from Products.contentmigration.walker import CustomQueryWalker from Products.contentmigration.archetypes import InplaceATItemMigrator class FalconImageMigrator(InplaceATItemMigrator): walker = CustomQueryWalker src_meta_type = "FalconImage" src_portal_type = "FalconImage" dst_meta_type = "ATBlob" dst_portal_type = "Image" # Following stolen from plone.app.blob.migrations, ATImageToBlobImageMigrator # migrate all fields except 'image', which needs special handling... fields_map = { 'image': None, } def migrate_data(self): self.new.getField('image').getMutator(self.new)(self.old) # ATFileToBlobMigrator reindexes certain fields. Otherwise we # need to clear and rebuild the entire catalog. def last_migrate_reindex(self): self.new.reindexObject(idxs=['object_provides', 'portal_type', 'Type', 'UID']) migrator = FalconImageMigrator walker = migrator.walker(portal, FalconImageMigrator) walker.go() print walker.getOutput() 

Complications:

  • The image is a little strange as the type of destination, as the data is transferred to the blob storage.

  • We need to update the directory so that the "resolveuid / UID" links created by TinyMCE continue to work. last_migrate_reindex () in the Migrator class should be faster than flushing and restoring the entire directory from scratch.

+1
source

All Articles