changeset 2589:2815c91635ff

1.6 converter: improve user profile conversion
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 02 Aug 2007 21:44:46 +0200
parents 5ae633bf2de5
children 20638e764560
files MoinMoin/script/migration/1050800.py MoinMoin/script/migration/1059999.py MoinMoin/script/migration/_conv160.py
diffstat 3 files changed, 28 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/migration/1050800.py	Mon Jul 23 13:00:13 2007 +0300
+++ b/MoinMoin/script/migration/1050800.py	Thu Aug 02 21:44:46 2007 +0200
@@ -11,7 +11,7 @@
 
 def execute(script, data_dir, rev):
     # the first pass just creates <data_dir>/rename1.txt
-    dc = DataConverter(data_dir, None)
+    dc = DataConverter(None, data_dir, None) # XXX TODO None -> script.request
     dc.pass1()
     return 1059999
 
--- a/MoinMoin/script/migration/1059999.py	Mon Jul 23 13:00:13 2007 +0300
+++ b/MoinMoin/script/migration/1059999.py	Thu Aug 02 21:44:46 2007 +0200
@@ -26,7 +26,7 @@
     src_data_dir = os.path.abspath(os.path.join(data_dir, '..', 'data.pre160')) # keep the orig data_dir here
     dst_data_dir = data_dir
     shutil.move(data_dir, src_data_dir)
-    dc = DataConverter(src_data_dir, dst_data_dir)
+    dc = DataConverter(None, src_data_dir, dst_data_dir) # XXX TODO None -> script.request
     dc.pass2()
     return 1060000
 
--- a/MoinMoin/script/migration/_conv160.py	Mon Jul 23 13:00:13 2007 +0300
+++ b/MoinMoin/script/migration/_conv160.py	Thu Aug 02 21:44:46 2007 +0200
@@ -27,23 +27,29 @@
        old         attachment:file%20with%20blanks.txt
        new         attachment:"file with blanks.txt"
 
+    c) users: move bookmarks from separate files into user profile
+    d) users: generate new name[] for lists and name{} for dicts
 
     TODO:
         * process page content / convert markup
-        * rename pages in user subscribed pages
-        * rename pages in user quicklinks
 
     DONE:
         pass 1
         * creating the rename.txt works
         pass 2
-        * renaming of pagedirs works
+        * renaming of pages works
+         * renamed pagedirs
          * renamed page names in global edit-log
          * renamed page names in local edit-log
          * renamed page names in event-log
+         * renamed pages in user subscribed pages
+         * renamed pages in user quicklinks
         * renaming of attachments works
+         * renamed attachment files
          * renamed attachment names in global edit-log
          * renamed attachment names in local edit-log
+        * migrate separate user bookmark files into user profiles
+        * support new dict/list syntax in user profiles
 
     @copyright: 2007 by Thomas Waldmann
     @license: GNU GPL, see COPYING for details.
@@ -352,18 +358,24 @@
                 pages = value.decode('utf-8').split(u'\t')
                 for i in range(len(pages)):
                     pagename = pages[i]
-                    # XXX strip wiki name from interwiki link here
+                    try:
+                        interwiki, pagename = pagename.split(':', 1)
+                    except:
+                        interwiki, pagename = 'Self', pagename
+                    # XXX we should check that interwiki == own wikiname
                     if ('PAGE', pagename) in self.renames:
-                        pages[i] = self.renames[('PAGE', pagename)]
+                        pagename = self.renames[('PAGE', pagename)]
+                        pages[i] = '%s:%s' % (interwiki, pagename)
+                key += '[]' # we have lists here
                 value = u'\t'.join(pages).encode('utf-8')
-            f.write("%s=%s\n" % (key, value))
+                f.write("%s=%s\n" % (key, value))
+            else:
+                f.write("%s=%s\n" % (key, value))
+        bookmark_entries = [u'%s:%s' % item for item in self.bookmarks.items()]
+        key = "bookmarks{}"
+        value = u'\t'.join(bookmark_entries).encode('utf-8')
+        f.write("%s=%s\n" % (key, value))
         f.close()
-        # write bookmarks XXX check if we can use the new integrated bookmarks
-        for wiki, bookmark in self.bookmarks.items():
-            fname = opj(users_dir, "%s.%s.bookmark" % (self.uid, wiki))
-            f = file(fname, "w")
-            f.write("%d\n" % bookmark)
-            f.close()
         # don't care about trail
 
     def copy(self, users_dir, renames):
@@ -373,7 +385,8 @@
 
 
 class DataConverter(object):
-    def __init__(self, src_data_dir, dest_data_dir):
+    def __init__(self, request, src_data_dir, dest_data_dir):
+        self.request = request # XXX TODO make it available in every object
         self.sdata = src_data_dir
         self.ddata = dest_data_dir
         self.pages = {}