changeset 5923:50a2730d2f95

merged
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 19 Jan 2013 00:33:07 +0100
parents 25900eaeb864 (current diff) 38b39fafc5dc (diff)
children 9894a3344118
files
diffstat 2 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Sat Jan 19 00:32:21 2013 +0100
+++ b/MoinMoin/PageEditor.py	Sat Jan 19 00:33:07 2013 +0100
@@ -12,7 +12,7 @@
 
     @copyright: 2000-2004 by Juergen Hermann <jh@web.de>,
                 2005-2007 by MoinMoin:ThomasWaldmann,
-                2007 by MoinMoin:ReimarBauer
+                2007-2013 by MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -88,6 +88,8 @@
         @keyword do_revision_backup: if 0, suppress making a page backup per revision
         @keyword do_editor_backup: if 0, suppress saving of draft copies
         @keyword uid_override: override user id and name (default None)
+        @keyword mtime: time for edit-log and event-log (using current time in UTC, if not given)
+                        number of seconds since the epoch, see the time module
         """
         Page.__init__(self, request, page_name, **keywords)
         self._ = request.getText
@@ -95,6 +97,7 @@
         self.do_revision_backup = keywords.get('do_revision_backup', 1)
         self.do_editor_backup = keywords.get('do_editor_backup', 1)
         self.uid_override = keywords.get('uid_override', None)
+        self.mtime = keywords.get('mtime')
 
         self.lock = PageLock(self)
 
@@ -996,6 +999,8 @@
             else:
                 filesys.rename(cltfn, clfn)
 
+            if self.mtime is not None:
+                mtime_usecs = self.mtime
             if not deleted:
                 # save to page file
                 pagefile = os.path.join(revdir, revstr)
@@ -1003,14 +1008,16 @@
                 # Write the file using text/* mime type
                 f.write(self.encodeTextMimeType(text))
                 f.close()
-                mtime_usecs = wikiutil.timestamp2version(os.path.getmtime(pagefile))
+                if self.mtime is None:
+                    mtime_usecs = os.path.getmtime(pagefile)
                 # set in-memory content
                 self.set_raw_body(text)
             else:
-                mtime_usecs = wikiutil.timestamp2version(time.time())
+                if self.mtime is None:
+                    mtime_usecs = time.time()
                 # set in-memory content
                 self.set_raw_body(None)
-
+            mtime_usecs = wikiutil.timestamp2version(mtime_usecs)
             # reset page object
             self.reset()
 
--- a/MoinMoin/script/import/wikipage.py	Sat Jan 19 00:32:21 2013 +0100
+++ b/MoinMoin/script/import/wikipage.py	Sat Jan 19 00:33:07 2013 +0100
@@ -2,13 +2,17 @@
 """
 MoinMoin - import wiki pages from local files into the wiki.
 
-@copyright: 2010 MoinMoin:PascalVolk
+@copyright: 2010 MoinMoin:PascalVolk,
+            2013 MoinMoin:ReimarBauer
+
 @license: GNU GPL, see COPYING for details.
 """
+import calendar
+import time
 
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.script import MoinScript, fatal, log
-from MoinMoin.wikiutil import clean_input, decodeUnknownInput
+from MoinMoin.wikiutil import clean_input, decodeUnknownInput, timestamp2version
 
 
 class IAmRoot(object):
@@ -36,6 +40,9 @@
         self.parser.add_option('--author', dest='author', metavar='AUTHOR',
                 default='PageImporter',
                 help='Use AUTHOR for edit history / RecentChanges')
+        self.parser.add_option('--mtime', dest='mtime', metavar='mtime',
+                default=None,
+                help='Use TIME (YYYY-MM-DD HH:MM:SS) in UTC for edit history / RecentChanges. Default value is the current UTC time')
         self.parser.add_option('--comment', dest='comment', metavar='COMMENT',
                 default='', help='COMMENT for edit history / RecentChanges')
         self.parser.add_option('--file', dest='file', default='',
@@ -69,8 +76,14 @@
             acl = '#acl %s\n' % self.options.acl
         comment = clean_input(self.options.comment)
 
+        if self.options.mtime:
+            mtime = timestamp2version(calendar.timegm(time.strptime(self.options.mtime, "%Y-%m-%d %H:%M:%S")))
+        else:
+            mtime = timestamp2version(time.time())
+
+
         pe = PageEditor(request, self.options.page, do_editor_backup=0,
-                        uid_override=self.options.author,
+                        uid_override=self.options.author, mtime=mtime,
                         do_revision_backup=int(self.options.revision_backup))
         try:
             pe.saveText(acl + page_content, 0, comment=comment)