Portal_migration bug in 5.0.7 or have I been doing this wrong for years?

Hi folks. I've been using an "instance run" script to upgrade Plone sites that's been working for years; it basically is this:

from Testing import makerequest
… other imports …
app = makereqeust.makerequest(app)
acl_users = app.acl_users
setSecurityPolicy(PermissiveSecurityPolicy())
newSecurityManageer(None, OmnipotentUser().__of__(acl_users))
portal = app.unrestrcitedTraverse('plone')
portal.setupCurrentSkin(app.REQUEST)
setSite(portal)
migration = getToolByName(portal, 'portal_migration')
migration.upgrade(dry_run=False)

This has served me from Plone 4 all the way to Plone 5.0.6. However, when trying to upgrade to Plone 5.0.7, I get a stack trace:

2017-03-24 17:11:24 ERROR plone.app.upgrade Upgrade aborted. Error:
Traceback (most recent call last):
  File "/Users/kelly/.buildout/eggs/Products.CMFPlone-5.0.7-py2.7.egg/Products/CMFPlone/MigrationTool.py", line 268, in upgrade
    step['step'].doStep(setup)
  File "/Users/kelly/.buildout/eggs/Products.GenericSetup-1.8.6-py2.7.egg/Products/GenericSetup/upgrade.py", line 166, in doStep
    self.handler(tool)
  File "/Users/kelly/.buildout/eggs/plone.app.upgrade-2.0.1-py2.7.egg/plone/app/upgrade/v50/final.py", line 103, in to507
    loadMigrationProfile(context, 'profile-plone.app.upgrade.v50:to507')
  File "/Users/kelly/.buildout/eggs/plone.app.upgrade-2.0.1-py2.7.egg/plone/app/upgrade/utils.py", line 200, in loadMigrationProfile
    context.runAllImportStepsFromProfile(profile, purge_old=False)
  File "/Users/kelly/.buildout/eggs/Products.GenericSetup-1.8.6-py2.7.egg/Products/GenericSetup/tool.py", line 388, in runAllImportStepsFromProfile
    dependency_strategy=dependency_strategy)
  File "/Users/kelly/.buildout/eggs/Products.GenericSetup-1.8.6-py2.7.egg/Products/GenericSetup/tool.py", line 1433, in _runImportStepsFromContext
    message = self._doRunImportStep(step, context)
  File "/Users/kelly/.buildout/eggs/Products.GenericSetup-1.8.6-py2.7.egg/Products/GenericSetup/tool.py", line 1245, in _doRunImportStep
    return handler(context)
  File "/Users/kelly/.buildout/eggs/Products.CMFPlone-5.0.7-py2.7.egg/Products/CMFPlone/resources/exportimport/bundles.py", line 28, in combine
    combine_bundles(site)
  File "/Users/kelly/.buildout/eggs/Products.CMFPlone-5.0.7-py2.7.egg/Products/CMFPlone/resources/browser/combine.py", line 142, in combine_bundles
    write_js(context, production_folder, 'default')
  File "/Users/kelly/.buildout/eggs/Products.CMFPlone-5.0.7-py2.7.egg/Products/CMFPlone/resources/browser/combine.py", line 72, in write_js
    registry.records['plone.resources/jquery.js'].value))
  File "/Users/kelly/.buildout/eggs/Products.CMFPlone-5.0.7-py2.7.egg/Products/CMFPlone/resources/browser/combine.py", line 46, in get_resource
    resource = context.unrestrictedTraverse(path)
  File "/Users/kelly/.buildout/eggs/Zope2-2.13.26-py2.7.egg/OFS/Traversable.py", line 274, in unrestrictedTraverse
    next = queryMultiAdapter((obj, aq_acquire(self, 'REQUEST')),
AttributeError: REQUEST
2017-03-24 17:11:24 ERROR plone.app.upgrade The upgrade path did NOT reach current version.
2017-03-24 17:11:24 ERROR plone.app.upgrade Migration has failed

So, the question is: is this a bug in 5.0.7? Or have I been going about this incorrectly?

Thanks!

Well, whatever was causing this issue in 5.0.7 is gone in 5.0.8.

I've seen this happen occasionally with various versions of Plone 5. @rpatterson got it fixed for us today by changing:

pm = getToolByName(portal, 'portal_migration')

to:

pm = getattr(portal, 'portal_migration', getToolByName(portal, 'portal_migration'))
2 Likes