Commits

Andreas Kloeckner committed b955b06

Adapt import19 for namespaces.

Comments (0)

Files changed (1)

MoinMoin/script/migration/moin19/import19.py

 
 from MoinMoin.constants.keys import *
 from MoinMoin.constants.contenttypes import CONTENTTYPE_USER
+from MoinMoin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERPROFILES
 
 UID_OLD = 'old_user_id'  # dynamic field *_id, so we don't have to change schema
 
             # handle deleted revisions (for all revnos with 0<=revno<=current) here
             # we prepare some values for the case we don't find a better value in edit-log:
             meta = {MTIME: -1,  # fake, will get 0 in the end
-                    NAME: item_name,  # will get overwritten with name from edit-log
+                    NAME: [item_name],  # will get overwritten with name from edit-log
                                       # if we have an entry there
                    }
             try:
             except KeyError:
                 if 1 <= revno <= item.current:
                     editlog_data = {  # make something up
-                        NAME: item.name,
+                        NAME: [item.name],
                         MTIME: int(os.path.getmtime(path)),
                         ACTION: u'SAVE',
                     }
         meta[SIZE] = size
         meta[ITEMID] = itemid
         meta[REVID] = make_uuid()
+        meta[NAMESPACE] = NAMESPACE_DEFAULT
         self.meta = {}
         for k, v in meta.iteritems():
             if isinstance(v, list):
                 MTIME: int(os.path.getmtime(attpath)),
                 ACTION: u'SAVE',
             }
-        meta[NAME] = u'{0}/{1}'.format(item_name, attach_name)
+        meta[NAME] = [u'{0}/{1}'.format(item_name, attach_name)]
         if acl is not None:
             meta[ACL] = acl
         meta[CONTENTTYPE] = unicode(MimeType(filename=attach_name).content_type())
         # do some conversions/cleanups/fallbacks:
         result[MTIME] = int(long(result[MTIME] or 0) / 1000000)  # convert usecs to secs
         result['__rev'] = int(result['__rev']) - 1  # old storage is 1-based, we want 0-based
-        result[NAME] = unquoteWikiname(result[NAME])
+        result[NAME] = [unquoteWikiname(result[NAME])]
         action = result[ACTION]
         extra = result[EXTRA]
         if extra:
         for key, default in int_defaults:
             metadata[key] = int(metadata.get(key, default))
 
+        metadata[NAMESPACE] = NAMESPACE_USERPROFILES
+        metadata[NAME] = [metadata[NAME]]
+
         # rename last_saved to MTIME, int MTIME should be enough:
         metadata[MTIME] = int(float(metadata.get('last_saved', '0')))