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)

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

Reply via email to