changeset 122:e90768ec963c

cleanup some NAME/UUID stuff fs19: add NAME to item metadata of pages and attachments. Note: we already have NAME ('name') item metadata for user profile items, it is the user's name - but the profile item name is different: "UserProfile/<uuid>" - we have to solve that conflict later. Also the user profile item NAME metadata (e.g. "JoeDoe") can easily conflict with a content item name (his homepage, also named "JoeDoe"). indexing: use the item UUID, don't fake it do not put (item) UUID into metadata editor
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 14 Mar 2011 02:07:59 +0100
parents 9b1f916249b8
children d8615f4b59e2
files MoinMoin/items/__init__.py MoinMoin/storage/backends/fs19.py MoinMoin/storage/backends/indexing.py
diffstat 3 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Sun Mar 13 23:31:10 2011 +0100
+++ b/MoinMoin/items/__init__.py	Mon Mar 14 02:07:59 2011 +0100
@@ -280,6 +280,7 @@
                      NAME_OLD,
                      # are automatically implanted when saving
                      NAME,
+                     UUID,
                      HASH_ALGORITHM,
                      SIZE,
                      COMMENT,
--- a/MoinMoin/storage/backends/fs19.py	Sun Mar 13 23:31:10 2011 +0100
+++ b/MoinMoin/storage/backends/fs19.py	Mon Mar 14 02:07:59 2011 +0100
@@ -294,6 +294,7 @@
                 raise NoSuchItemError('deleted_mode wants killing/ignoring of page %r and its attachments' % itemname)
         uuid = backend.idx.content_uuid(itemname)
         self.uuid = self._fs_meta[UUID] = uuid
+        self._fs_meta[NAME] = itemname
 
     def iter_attachments(self):
         attachmentspath = self._backend._get_item_path(self.name, 'attachments')
@@ -459,6 +460,7 @@
         self._syspages = backend._syspages
         uuid = backend.idx.content_uuid(name)
         self.uuid = self._fs_meta[UUID] = uuid
+        self._fs_meta[NAME] = name
 
 class FsAttachmentRevision(StoredRevision):
     """ A moin 1.9 filesystem item revision (attachment) """
--- a/MoinMoin/storage/backends/indexing.py	Sun Mar 13 23:31:10 2011 +0100
+++ b/MoinMoin/storage/backends/indexing.py	Mon Mar 14 02:07:59 2011 +0100
@@ -147,14 +147,14 @@
         this is automatically called by item.commit() and can be used by a indexer script also.
         """
         name = self.item.name
-        uuid = name # XXX
+        uuid = self.item[UUID]
         revno = self.revno
         if MTIME not in self:
             self[MTIME] = int(time.time())
         if NAME not in self:
             self[NAME] = name
         if UUID not in self:
-            self[UUID] = uuid
+            self[UUID] = uuid # do we want the item's uuid in the rev's metadata?
         if MIMETYPE not in self:
             self[MIMETYPE] = 'application/octet-stream'
         metas = self
@@ -168,10 +168,10 @@
         update the index, removing everything related to this revision
         """
         name = self.item.name
+        uuid = self.item[UUID]
         revno = self.revno
         metas = self
         logging.debug("item %r revno %d remove index!" % (name, revno))
-        uuid = name # XXX
         self._index.remove_rev(uuid, revno)
 
     # TODO maybe use this class later for data indexing also,
@@ -256,8 +256,8 @@
 
         note: if item does not exist already, it is added
         """
-        name = metas.get(NAME, '') # item name (if revisioned: same as current revision's name) XXX not there yet
-        uuid = metas.get(UUID, name) # item uuid (never changes) XXX we use name as long we have no uuid
+        name = metas.get(NAME, '') # item name (if revisioned: same as current revision's name)
+        uuid = metas.get(UUID, '') # item uuid (never changes)
         item_table = self.item_table
         item_id = self.get_item_id(uuid)
         if item_id is None:
@@ -286,8 +286,8 @@
         note: does not remove revisions, these should be removed first
         """
         item_table = self.item_table
-        name = metas.get(NAME, '') # item name (if revisioned: same as current revision's name) XXX not there yet
-        uuid = metas.get(UUID, name) # item uuid (never changes) XXX we use name as long we have no uuid
+        name = metas.get(NAME, '') # item name (if revisioned: same as current revision's name)
+        uuid = metas.get(UUID, '') # item uuid (never changes)
         item_id = self.get_item_id(uuid)
         if item_id is not None:
             self.item_kvstore.store_kv(item_id, {})