changeset 3060:dae64bd781ad

Added a --dump-user option to the moin dump command. Thanks to Oliver O'Halloran. (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 21 Feb 2008 20:49:28 +0100
parents 036fc4dce2ee
children 861407f630b4
files MoinMoin/script/export/dump.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/export/dump.py	Thu Feb 21 20:43:42 2008 +0100
+++ b/MoinMoin/script/export/dump.py	Thu Feb 21 20:49:28 2008 +0100
@@ -13,7 +13,7 @@
 
 import sys, os, time, codecs, shutil, re, errno
 
-from MoinMoin import config, wikiutil, Page
+from MoinMoin import config, wikiutil, Page, user
 from MoinMoin import script
 from MoinMoin.action import AttachFile
 
@@ -52,6 +52,7 @@
 </html>
 '''
 
+
 def _attachment(request, pagename, filename, outputdir):
     filename = filename.encode(config.charset)
     source_dir = AttachFile.getAttachDir(request, pagename)
@@ -81,8 +82,12 @@
     def __init__(self, argv=None, def_values=None):
         script.MoinScript.__init__(self, argv, def_values)
         self.parser.add_option(
-            "-t", "--target-dir", dest="target_dir",
-            help="Write html dump to DIRECTORY"
+            "-t", "--target-dir", dest = "target_dir",
+            help = "Write html dump to DIRECTORY"
+        )
+        self.parser.add_option(
+            "-u", "--username", dest = "dump_user",
+            help = "User the dump will be performed as (for ACL checks, etc)"
         )
 
     def mainloop(self):
@@ -113,6 +118,9 @@
         # fix url_prefix_static so we get relative paths in output html
         request.cfg.url_prefix_static = url_prefix_static
 
+        # use this user for permissions checks
+        request.user = user.User(request, auth_username = self.options.dump_user)
+
         pages = request.rootpage.getPageList(user='') # get list of all pages in wiki
         pages.sort()
         if self.options.page: # did user request a particular page or group of pages?