MoinMoin 復活

MoinMoin をバージョンアップして復活させました。
実は、結構苦労しました。以前から UTF-8 を使っていたんですが、migration スクリプトが素直に動かないのです。もちろん、from_encoding を utf-8 にしましたよ。

  • mig1 については、一つ処理できないドキュメント(というかディレクトリ)があったので、これは削除しちゃいました。そもそも、page/ だけあって、text/ がないのです。ページが壊れていたのかもしれません。
  • mig6 については、これはもう全然だめです。下のような修正を加えて、とりあえず UTF-8 に変換できないログの行は無視させました。
  --- ORIG/12_to_13_mig6.py       Mon Dec 13 08:26:00 2004
  +++ 12_to_13_mig6.py    Thu Dec 30 13:57:03 2004
  @@ -43,7 +43,8 @@
       @license: GPL, see COPYING for details
   """
   
  -from_encoding = 'iso8859-1'
  +from_encoding = 'utf-8'
  +# from_encoding = 'iso8859-1'
   to_encoding = 'utf-8'
   
   import os.path, sys, shutil, urllib
  @@ -54,7 +55,11 @@
   from migutil import opj, listdir, copy_file, copy_dir
   
   def convert_string(str, enc_from, enc_to):
  -    return str.decode(enc_from).encode(enc_to)
  +    try:
  +        s = str.decode(enc_from).encode(enc_to)
  +        return s
  +    except UnicodeDecodeError:
  +        return None
   
   def convert_eventlog(fname_from, fname_to, enc_from, enc_to):
       print "%s -> %s" % (fname_from, fname_to)
  @@ -62,6 +67,7 @@
       file_to = open(fname_to, "w")
           
       for line in file_from:
  +        dame = line
           line = line.replace('\r','')
           line = line.replace('\n','')
           fields = line.split('\t')
  @@ -73,7 +79,15 @@
               key = urllib.unquote(key)
               val = urllib.unquote(val)
               key = convert_string(key, enc_from, enc_to)
  +            if key == None:
  +                print '@@' + dame
  +                print '@@@ None key'
  +                continue
               val = convert_string(val, enc_from, enc_to)
  +            if val == None:
  +                print '@@' + dame
  +                print '@@@ None val'
  +                continue
               key = urllib.quote(key)
               val = urllib.quote(val)
               kvlist.append("%s=%s" % (key,val))

あと、アクセスコントロールACL)をオンにしたいけど、体力尽きました。