Added a --dump-user option to the moin dump command. Thanks to Oliver O'Halloran. (ported from 1.6)
authorReimar Bauer <rb.proj AT googlemail DOT com>
Thu, 21 Feb 2008 20:49:28 +0100
changeset 3060dae64bd781ad
parent 3059 036fc4dce2ee
child 3061 861407f630b4
Added a --dump-user option to the moin dump command. Thanks to Oliver O'Halloran. (ported from 1.6)
MoinMoin/script/export/dump.py
     1.1 --- a/MoinMoin/script/export/dump.py	Thu Feb 21 20:43:42 2008 +0100
     1.2 +++ b/MoinMoin/script/export/dump.py	Thu Feb 21 20:49:28 2008 +0100
     1.3 @@ -13,7 +13,7 @@
     1.4  
     1.5  import sys, os, time, codecs, shutil, re, errno
     1.6  
     1.7 -from MoinMoin import config, wikiutil, Page
     1.8 +from MoinMoin import config, wikiutil, Page, user
     1.9  from MoinMoin import script
    1.10  from MoinMoin.action import AttachFile
    1.11  
    1.12 @@ -52,6 +52,7 @@
    1.13  </html>
    1.14  '''
    1.15  
    1.16 +
    1.17  def _attachment(request, pagename, filename, outputdir):
    1.18      filename = filename.encode(config.charset)
    1.19      source_dir = AttachFile.getAttachDir(request, pagename)
    1.20 @@ -81,8 +82,12 @@
    1.21      def __init__(self, argv=None, def_values=None):
    1.22          script.MoinScript.__init__(self, argv, def_values)
    1.23          self.parser.add_option(
    1.24 -            "-t", "--target-dir", dest="target_dir",
    1.25 -            help="Write html dump to DIRECTORY"
    1.26 +            "-t", "--target-dir", dest = "target_dir",
    1.27 +            help = "Write html dump to DIRECTORY"
    1.28 +        )
    1.29 +        self.parser.add_option(
    1.30 +            "-u", "--username", dest = "dump_user",
    1.31 +            help = "User the dump will be performed as (for ACL checks, etc)"
    1.32          )
    1.33  
    1.34      def mainloop(self):
    1.35 @@ -113,6 +118,9 @@
    1.36          # fix url_prefix_static so we get relative paths in output html
    1.37          request.cfg.url_prefix_static = url_prefix_static
    1.38  
    1.39 +        # use this user for permissions checks
    1.40 +        request.user = user.User(request, auth_username = self.options.dump_user)
    1.41 +
    1.42          pages = request.rootpage.getPageList(user='') # get list of all pages in wiki
    1.43          pages.sort()
    1.44          if self.options.page: # did user request a particular page or group of pages?