[Setup] Re: Migration 2.0.5 -> 2.1.1 failed
Raphael Ritz
r.ritz at biologie.hu-berlin.de
Thu Nov 24 11:26:38 UTC 2005
Nick Davis wrote:
> alan runyan wrote:
>
>> Nick
>>
>> Would you be up for writing a simple "How to debug a migration error"?
>>
>> Alan
>>
>>
>
> OK. I will try to put something together. I am no expert though, please
> be warned. In the meantime, Raphael Ritz's document on debugging Plone
> is very useful :
>
> http://docs.neuroinf.de/programming-plone/debug
>
> Maybe that ought to be copied to the plone.org HOWTOs ?
>
Which reminds me that I've promised a while ago to do that
myself. Still waiting for plone.org to be updated, so working
TTP would not be such a pain anymore.
Raphael
PS: Some input for your migration how-to:
Here something cut-and-past from how I do one
currently. Note that this wasn't written to be
published nor to be generic in any way. It contains
reference to custom products and is purely site specific.
Use at your own risc or better yet: just take
it as an inspiration.
#
# bccn.py
#
# by Raphael Ritz, November 2005
#
# migrate the BCCN-Berlin site to Plone 2.1(.1)
#
# Usage:
#
# Place the 'migrationTo21' folder in INSTANCE_HOME/bin
# of the new Zope/Plone instance. Copy over the Data.fs
# from the current site's ZEO server.
# Stop the site (if running) and invoke the migration with
#
# zopectl run migrationTo21/bccn.py
#
# Be patient
# (on my machine it currently takes about 10 minutes to complete)
# Prints progress to stdout and to a custom log file
# called 'migration.log'.
#
try:
from utils import *
except ImportError:
from migrationTo21.utils import *
# global settings
site_id = 'cns-berlin'
top_folder_ids = ('overview',
'ResearchGroups',
'People',
'projects',
'talks',
'meetings',
'positions',
'publications',
'Teaching',
'coordination',
)
action_ids = ('news',
'ResearchGroups',
'projects',
'People',
'positions',
'bibliography_view',
'Teaching',
'coordination',
)
action_providers = ('portal_actions',
'portal_bibliography',
'lab_utils',
)
types_to_list = ('ApplicationFolder',
'BibliographyFolder',
'LargeBibliographyFolder',
'EventFolder',
'Large Plone Folder',
'Folder',
'ResearchGroup',
'Topic',
)
ids_not_to_list = ('news', 'old_events')
# detect these automatically?
broken_folders = [
'intern/logos',
'intern/hu-campus-nord',
]
catalog_ids = ('portal_catalog',
'uid_catalog',
'reference_catalog'
)
# short cuts
site = app[site_id]
at = site['archetype_tool']
qi = site['portal_quickinstaller']
tt = site['portal_types']
mt = site['portal_migration']
# here we go
login(site=app)
mlog = MyLogger()
# handle CMFBib
mlog('Reinstalling CMFBibliographyAT')
qi.reinstallProducts(['CMFBibliographyAT'])
commit()
mlog('Starting schema update for bib folders')
request = FakeRequest()
request.form = {'CMFBibliographyAT.BibliographyFolder': True,
'CMFBibliographyAT.LargeBibliographyFolder': True,
}
at.manage_updateSchema(request)
commit()
mlog('Done with schema update for bib folders')
# save request for later
site.REQUEST = request
# "Fixing catalogs"
for id in catalog_ids:
mlog("Fixing '%s'" % id)
catalog = site[id]
catalog.manage_convertIndexes()
catalog()
# handle ATCT
mlog('Installing ATCT')
qi.installProducts(['ATContentTypes'])
commit()
atct_tool = site['portal_atct']
mlog('Starting ATCT version migration')
atct_tool.upgrade()
commit()
mlog('ATCT type migration 1(3): changing type')
atct_tool.migrateContentTypesToATCT()
commit()
mlog('ATCT type migration 2(3): update workflow')
atct_tool.migrationUpdateWorkflowRoleMapping()
commit()
mlog('ATCT type migration 3(3): update catalog')
atct_tool.migrationRefreshPortalCatalog()
commit()
# now migrate Plone itself
mlog('Starting Plone site migration')
mt.upgrade()
commit()
mlog('Done with Plone site migration')
# fix broken folders
for folder in broken_folders:
mlog("Fixing '%s'" % folder)
f = site.unrestrictedTraverse(folder)
tt['CMF Folder']._finishConstruction(f)
atct_tool.migrateContentTypesToATCT()
for folder in broken_folders:
f = site.unrestrictedTraverse(folder)
f.reindexObject()
commit()
# fix some portal settings
mlog('Changing folder icon')
tt['Folder'].content_icon = 'topic_icon.gif'
mlog("Setting 'metaTypesNotToList' and 'idsNotToList'")
not_to_list = []
for fti in tt.objectIds():
if fti not in types_to_list:
not_to_list.append(fti)
prop_sheet = site.portal_properties.navtree_properties
prop_sheet.manage_changeProperties(metaTypesNotToList=not_to_list)
idsNotToList = prop_sheet.getProperty('idsNotToList')
idsNotToList += ids_not_to_list
prop_sheet.manage_changeProperties(idsNotToList=idsNotToList)
mlog('Setting top-level folder order')
site.moveObjectsToTop(ids=top_folder_ids)
## mlog("Remove custom 'portal_tab' actions")
## for provider in action_providers:
## tool = site[provider]
## for action in tool._actions:
## if action.id in action_ids:
## action.visible = 0
mlog('Disable auto tab generation')
prop_sheet = site.portal_properties.site_properties
prop_sheet.manage_changeProperties(disable_folder_sections=True)
# remove our faked request
del site.REQUEST
mlog('Finally pack the database')
app.Control_Panel.Database['main'].manage_pack()
commit()
mlog('Done')
##### and the utils file ##########
# some utilities
import transaction
from DateTime import DateTime
from AccessControl.SecurityManagement import newSecurityManager
def commit(): # change comment to en/disable
pass
# transaction.commit()
def login(user_id='admin', site=None):
# user has to live in site's acl_users
if site is None:
site = app
user = site.acl_users.getUserById(user_id)
user = user.__of__(site.acl_users)
newSecurityManager(None, user)
class MyLogger:
def __init__(self, file_id='migration.log'):
self.file = file(file_id, 'w')
def __call__(self, text):
self.file.write("\n%s:\n" % DateTime().ISO())
self.file.write(text)
self.file.write("\n%s" % (60*'='))
self.file.flush()
print text
class FakeRequest:
def __init__(self):
self.form = {}
def get(self, key, default=None):
return self.form.get(key, default)
def __getitem__(self, key):
return self.get(key)
def _hold(self, data):
pass
def __len__(self):
return 0
More information about the Setup
mailing list