1#!/usr/bin/env python 2""" 3 migration from moin 1.2 to moin 1.3 4 For 1.3, the plugin module loader needs some __init__.py files. 5 Although we supply those files in the new "empty wiki template" in 6 wiki/data, many people forgot to update their plugin directories, 7 so we do that via this mig script now. 8 9 Steps for a successful migration: 10 11 1. Stop your wiki and make a backup of old data and code 12 13 2. Make a copy of the wiki's "data" directory to your working dir 14 15 3. If there was no error, you will find: 16 data.pre-mig11 - the script renames your data directory copy to that name 17 data - converted data dir 18 19 4. Copy additional files from data.pre-mig11 to data (maybe intermaps, logs, 20 etc.). Be aware that the file contents AND file names of wiki content 21 may have changed, so DO NOT copy the files inside the cache/ directory, 22 let the wiki refill it. 23 24 5. Replace the data directory your wiki uses with the data directory 25 you created by previous steps. DO NOT simply copy the converted stuff 26 into the original or you will duplicate pages and create chaos! 27 28 6. Test it - if something has gone wrong, you still have your backup. 29 30 31 @copyright: 2005 Thomas Waldmann 32 @license: GPL, see COPYING for details 33""" 34 35import os.path, sys, urllib 36 37# Insert THIS moin dir first into sys path, or you would run another 38# version of moin! 39sys.path.insert(0, '../../../..') 40from MoinMoin import wikiutil 41 42from MoinMoin.script.migration.migutil import opj, listdir, copy_file, move_file, copy_dir, makedir 43 44def migrate(destdir): 45 plugindir = opj(destdir, 'plugin') 46 makedir(plugindir) 47 fname = opj(plugindir, '__init__.py') 48 f = open(fname, 'w') 49 f.write('''\ 50# *** Do not remove this! *** 51# Although being empty, the presence of this file is important for plugins 52# working correctly. 53''') 54 f.close() 55 for d in ['action', 'formatter', 'macro', 'parser', 'processor', 'theme', 'xmlrpc', ]: 56 thisdir = opj(plugindir, d) 57 makedir(thisdir) 58 fname = opj(thisdir, '__init__.py') 59 f = open(fname, 'w') 60 f.write('''\ 61# -*- coding: iso-8859-1 -*- 62 63from MoinMoin.util import pysupport 64 65modules = pysupport.getPackageModules(__file__) 66''') 67 f.close() 68 69origdir = 'data.pre-mig11' 70destdir = 'data' 71 72# Backup original dir and create new empty dir 73try: 74 os.rename(destdir, origdir) 75except OSError: 76 print "You need to be in the directory where your copy of the 'data' directory is located." 77 sys.exit(1) 78 79copy_dir(origdir, destdir) 80migrate(destdir) 81 82 83