#print
#print "Running set_method_aliases widget"
#set_method_aliases(portal)
#print "done"

print "Installing portal_geocoder"
qi = portal.portal_quickinstaller
qi.installProducts(['PleiadesGeocoder'])
print "done"
transaction.get().note('Installed portal_geocoder')
transaction.commit()

#this needs to run after the other transaction has been run
print "Running migrate_history..."
path = '/'.join(portal.getPhysicalPath() + ('projects',))
utils.migrate_history(portal, path, out=sys.stdout, save=False)
print "done"
transaction.get().note('wiki history migrated')
transaction.commit()
print "migrate_history transaction done"

print "Updating membrane catalog"
run_import_step(ps, 'membranetool')
print "done"
transaction.get().note('membrane_tool reconfigured')
transaction.commit()

print "Reindexing membrane catalog"
portal.membrane_tool.refreshCatalog()
transaction.get().note('membrane_tool reindexed')
transaction.commit()
from AccessControl.SecurityManagement import newSecurityManager
from itertools import count
from opencore.nui.wiki import utils
from pprint import pprint 
import sys
import transaction as txn

username = '******'
user = app.acl_users.getUser(username)
user = user.__of__(app.acl_users)
newSecurityManager(app, user)

try:
    portal = sys.argv[1]
except IndexError:
    portal = 'openplans'

try:
    noskip = sys.argv[2]
    noskip = noskip == '--noskip'
except IndexError:
    noskip = False

portal = getattr(app, portal)
path = '/'.join(portal.getPhysicalPath() + ('projects',))

print utils.migrate_history(portal, path, noskip=noskip).getvalue()