Permalink
Browse files

* Reach into CMFEditions' guts to make it store the data we want

** Override auto-created timestamp and principal IDs
   to have accurate records of commit dates and committers
** Technically we could do this without reaching into the guts,
   by setting the current logged-in principal to the committer
   for each commit; but that's stupid
* After storing all the history data, ping the opencore wiki
  history cache on all wikipages so that the web UI will display
  the history correctly and efficiently
  • Loading branch information...
1 parent 73f484a commit 0d73a43f0e07261b2cd80518b07fb403ef597c19 @ejucovy ejucovy committed Mar 5, 2012
Showing with 15 additions and 3 deletions.
  1. +15 −3 opencore/scripts/import_wiki_to_project.py
@@ -44,7 +44,10 @@
bzr = BzrAccess(tempdir)
from DateTime import DateTime
+repo = getToolByName(project, 'portal_repository')
+archivist = getToolByName(project, 'portal_archivist')
+PAGES = set()
for revision in reversed(bzr.log("/")):
path = revision['href']
timestamp = revision['fields']['timestamp']
@@ -62,7 +65,8 @@
title = path.replace("-", " ").title()
project.invokeFactory("Document", id=path, title=title)
page_ctx = project[path]
-
+ PAGES.add(path)
+
page_ctx.getField("modification_date").set(page_ctx, mod_date)
from lxml.html import fromstring, tostring
try:
@@ -74,9 +78,17 @@
## if all goes well this will set lastModifiedAuthor
from opencore.project.browser.metadata import _update_last_modified_author
_update_last_modified_author(page_ctx, user_id)
+
+ sys_metadata = repo._prepareSysMetadata(commit_message)
+ sys_metadata['timestamp'] = mod_date.timeTime()
+ prep = archivist.prepare(page_ctx, {}, sys_metadata)
+ prep.metadata['sys_metadata']['principal'] = user_id
+ archivist.save(prep, autoregister=repo.autoapply)
+ prep.copyVersionIdFromClone()
- repo = getToolByName(page_ctx, 'portal_repository')
- repo.save(page_ctx, comment=commit_message)
+from opencore.nui.wiki.utils import cache_history
+for page in PAGES:
+ cache_history(project[page], repo)
import shutil
shutil.rmtree(tempdir)

0 comments on commit 0d73a43

Please sign in to comment.