Le 1 déc. 2010 à 11:12, Martijn Pieters a écrit :
> On Tue, Nov 30, 2010 at 16:53, Gilles Lenfant
> <[email protected]> wrote:
>> Some hints :
>
> I'm in the middle of a migration, including moving from
> FileSystemStorage to blobs, and I used the following method to deal
> with one FSS field. It is exceedingly simple:
>
> from cStringIO import StringIO
> from Products.Archetypes.Storage import AttributeStorage
> from iw.fss.FileSystemStorage import FileSystemStorage
> attr_storage = AttributeStorage()
> fss_storage = FileSystemStorage()
>
> def migratePublication(pub):
> field = pub.Schema()['Attachmentfile']
> content = StringIO(str(fss_storage.get('Attachmentfile', pub)))
> fss_storage.unset('Attachmentfile', pub)
> field.set(pub, content)
That's something like that.
In addition, read how I made the opposite in migrator.py
The object iw.fss.zcml.patchedTypesRegistry is a dict :
{content class : {field name: storage, ...}, ...}
in this dict, "storage" is the storage object used for the field
(AttributeStorage, BlobStorage, ...)
The migration loop should be the same as the one used for migrating xxxStorage
-> FSS in migrator.py (should perhaps be refactored into a generator since the
same loop will be used twice).
HTH too
--
Gilles Lenfant
>
> The method is called for each and every publication item, and it's
> really very simple. I didn't have to auto-detect what fields were
> affected though, not sure how you'd do that if that was needed. In my
> case 'Attachmentfile' is the field name to be migrated. I also
> completely ignore any mime-type; it depends on your use-case if you
> want to detect / migrate that information.
>
> Hope this is of some use to someone.
>
> --
> Martijn Pieters
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers