Back to index

moin  1.9.0~rc2
12_to_13_mig11.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003     migration from moin 1.2 to moin 1.3
00004     For 1.3, the plugin module loader needs some __init__.py files.
00005     Although we supply those files in the new "empty wiki template" in
00006     wiki/data, many people forgot to update their plugin directories,
00007     so we do that via this mig script now.
00008 
00009     Steps for a successful migration:
00010 
00011         1. Stop your wiki and make a backup of old data and code
00012 
00013         2. Make a copy of the wiki's "data" directory to your working dir
00014 
00015         3. If there was no error, you will find:
00016             data.pre-mig11 - the script renames your data directory copy to that name
00017             data - converted data dir
00018 
00019         4. Copy additional files from data.pre-mig11 to data (maybe intermaps, logs,
00020            etc.). Be aware that the file contents AND file names of wiki content
00021            may have changed, so DO NOT copy the files inside the cache/ directory,
00022            let the wiki refill it.
00023 
00024         5. Replace the data directory your wiki uses with the data directory
00025            you created by previous steps. DO NOT simply copy the converted stuff
00026            into the original or you will duplicate pages and create chaos!
00027 
00028         6. Test it - if something has gone wrong, you still have your backup.
00029 
00030 
00031     @copyright: 2005 Thomas Waldmann
00032     @license: GPL, see COPYING for details
00033 """
00034 
00035 import os.path, sys, urllib
00036 
00037 # Insert THIS moin dir first into sys path, or you would run another
00038 # version of moin!
00039 sys.path.insert(0, '../../../..')
00040 from MoinMoin import wikiutil
00041 
00042 from MoinMoin.script.migration.migutil import opj, listdir, copy_file, move_file, copy_dir, makedir
00043 
00044 def migrate(destdir):
00045     plugindir = opj(destdir, 'plugin')
00046     makedir(plugindir)
00047     fname = opj(plugindir, '__init__.py')
00048     f = open(fname, 'w')
00049     f.write('''\
00050 # *** Do not remove this! ***
00051 # Although being empty, the presence of this file is important for plugins
00052 # working correctly.
00053 ''')
00054     f.close()
00055     for d in ['action', 'formatter', 'macro', 'parser', 'processor', 'theme', 'xmlrpc', ]:
00056         thisdir = opj(plugindir, d)
00057         makedir(thisdir)
00058         fname = opj(thisdir, '__init__.py')
00059         f = open(fname, 'w')
00060         f.write('''\
00061 # -*- coding: iso-8859-1 -*-
00062 
00063 from MoinMoin.util import pysupport
00064 
00065 modules = pysupport.getPackageModules(__file__)
00066 ''')
00067         f.close()
00068 
00069 origdir = 'data.pre-mig11'
00070 destdir = 'data'
00071 
00072 # Backup original dir and create new empty dir
00073 try:
00074     os.rename(destdir, origdir)
00075 except OSError:
00076     print "You need to be in the directory where your copy of the 'data' directory is located."
00077     sys.exit(1)
00078 
00079 copy_dir(origdir, destdir)
00080 migrate(destdir)
00081 
00082