[SOLVED] Existing content migration to use Dexterity failed

Thanks:)
Into which file should the code be insert?

create it and run it like the first I posted as 'myfile.py' IIRC

I find that some wrong delete of files leads to the problem of "IndexError: 0".
So I copy blobstorage and Data.fs from my production again and all go well.
Now my site have migrated to plone 5.0.8 with Dexterity.
Then I will test it.

Thank you very much, gp54321 and espenmn.

When I try to upgrade this Plone5.0.8 to 5.1.1 through bin/buildout, it fails:

test@debian:/opt/plone508/zeocluster$ sudo -u plone_buildout bin/buildout
Updating zeoserver.
Updating client1.
Updating client2.
Updating backup.
Updating zopepy.
Updating unifiedinstaller.
Updating precompiler.
Compiling Python files.
File "/opt/plone508/buildout-cache/eggs/zodbpickle-0.7.0-py2.7-linux-x86_64.egg/zodbpickle/pickle_3.py", line 178
def init(self, file, protocol=None, *, fix_imports=True):
^
SyntaxError: invalid syntax

File "/opt/plone508/buildout-cache/eggs/zodbpickle-0.7.0-py2.7-linux-x86_64.egg/zodbpickle/pickletools_3.py", line 2049
print("%5d:" % pos, end=' ', file=out)
^
SyntaxError: invalid syntax

File "/opt/plone508/buildout-cache/eggs/zodbpickle-0.7.0-py2.7-linux-x86_64.egg/zodbpickle/tests/pickletester_3.py", line 145
class use_metaclass(object, metaclass=metaclass):
^
SyntaxError: invalid syntax

Compiling locale files.
Error while compiling /opt/plone508/buildout-cache/eggs/python_gettext-3.0-py2.7.egg/pythongettext/tests/test_escape.po
Error while compiling /opt/plone508/buildout-cache/eggs/python_gettext-3.0-py2.7.egg/pythongettext/tests/test5.po
Updating setpermissions.
setpermissions: Running # Dummy references to force this to execute after referenced parts
echo /opt/plone508/zeocluster/var/backups yes > /dev/null
chmod 600 .installed.cfg

Make sure anything we've created in var is r/w by our group

find /opt/plone508/zeocluster/var -type d -exec chmod 770 {} ; 2> /dev/null
find /opt/plone508/zeocluster/var -type f -exec chmod 660 {} ; 2> /dev/null
find /opt/plone508/zeocluster/var -type d -exec chmod 770 {} ; 2> /dev/null
find /opt/plone508/zeocluster/var -type f -exec chmod 660 {} ; 2> /dev/null
chmod 754 /opt/plone508/zeocluster/bin/*
chmod: changing permissions of '/opt/plone508/zeocluster/bin/buildout': Operation not permitted
chmod: changing permissions of '/opt/plone508/zeocluster/bin/easy_install': Operation not permitted
chmod: changing permissions of '/opt/plone508/zeocluster/bin/easy_install-2.7': Operation not permitted
Versions had to be automatically picked.
The following part definition lists the versions picked:
[versions]
plone.recipe.command = 1.1
plone.recipe.precompiler = 0.6

since your initial problem is solved you should create a new topic. People will not necessary read new follow-ups in a a topic they have looked at the beginning and seen as not concerning them, so you are not maximizing your chances for a reply. Anyway, these messages look scary and it's certainly not very clean to let them in buildout output, but they are not symptoms of a failure as such. You are seeing error messages about failure to compile python 3 files from a package compatible with python 2 and 3, while Plone is python 2 only at the moment, messages about non important files that are appearing in Plone buildout since eons, operations failing to change permissions of files that have already the right permission,
If your Plone 5.1 install fails it's not because of these messages. If it fails you should have a backtrace.