~ubuntu-branches/ubuntu/intrepid/moin/intrepid-updates

« back to all changes in this revision

Viewing changes to MoinMoin/scripts/migration/12_to_13_mig11.py

  • Committer: Bazaar Package Importer
  • Author(s): Sivan Greenberg
  • Date: 2006-07-09 19:28:02 UTC
  • Revision ID: james.westby@ubuntu.com-20060709192802-oaeuvt4v3e9300uj
Tags: 1.5.3-1ubuntu1
* Merge new debian version.
* Reapply Ubuntu changes:
    + debian/rules:
      - Comment out usage of control.ubuntu.in (doesn't fit!).
    + debian/control.in:
      - Dropped python2.3 binary package.
    + debian/control:
      - Dropped python2.3 binary, again.
      - Dropped python2.3-dev from Build-Depends-Indep.
    + debian/patches/001-attachment-xss-fix.patch:
      - Dropped this patch. It's now in upstream's distribution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
35
 
 
36
 
import os.path, sys, urllib
37
 
 
38
 
# Insert THIS moin dir first into sys path, or you would run another
39
 
# version of moin!
40
 
sys.path.insert(0, '../../..')
41
 
from MoinMoin import wikiutil
42
 
 
43
 
from migutil import opj, listdir, copy_file, move_file, copy_dir, makedir
44
 
 
45
 
def migrate(destdir):
46
 
    plugindir = opj(destdir, 'plugin')
47
 
    makedir(plugindir)
48
 
    fname = opj(plugindir, '__init__.py')
49
 
    f = open(fname, 'w')
50
 
    f.write('''\
51
 
# *** Do not remove this! ***
52
 
# Although being empty, the presence of this file is important for plugins
53
 
# working correctly.
54
 
''')
55
 
    f.close()
56
 
    for d in ['action', 'formatter', 'macro', 'parser', 'processor', 'theme', 'xmlrpc', ]:
57
 
        thisdir = opj(plugindir, d)
58
 
        makedir(thisdir)
59
 
        fname = opj(thisdir, '__init__.py')
60
 
        f = open(fname, 'w')
61
 
        f.write('''\
62
 
# -*- coding: iso-8859-1 -*-
63
 
 
64
 
from MoinMoin.util import pysupport
65
 
 
66
 
modules = pysupport.getPackageModules(__file__)
67
 
''')
68
 
        f.close()
69
 
 
70
 
origdir = 'data.pre-mig11'
71
 
destdir = 'data'
72
 
 
73
 
# Backup original dir and create new empty dir
74
 
try:
75
 
    os.rename(destdir, origdir)
76
 
except OSError:
77
 
    print "You need to be in the directory where your copy of the 'data' directory is located."
78
 
    sys.exit(1)
79
 
 
80
 
copy_dir(origdir, destdir)
81
 
migrate(destdir)
82
 
 
83