Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.export.package.PluginScript Class Reference
Inheritance diagram for MoinMoin.script.export.package.PluginScript:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.script.export.package.PluginScript:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 request
 argv
 def_values
 parser
 args

Detailed Description

\
Purpose:
========
This tool allows you to create a package of certain wiki pages.

Detailed Instructions:
======================
General syntax: moin [options] export package [package-options]

[options] usually should be:
--config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/

[package-options] see below:
0. You must run this script as owner of the wiki files, usually this is the
   web server user.

1. To package all non-system and non-underlay pages on a wiki to the file '~/mywiki.zip'
   moin ... export package --output ~/mywiki.zip

2. To package the pages 'FooBar' and 'TestPage' on a wiki to the file '~/mywiki.zip'
   moin ... export package --pages FooBar,TestPage --output ~/mywiki.zip

3. To package all pages matching the search term 'MoinMoin' on a wiki to the file '~/mywiki.zip'
   moin ... export package --search MoinMoin --output ~/mywiki.zip

4. Optionally, the --user argument could be added to any of the above examples,
   causing the script to respect ACLs.

5. Optionally, the --include_attachments argument could be added to any of the above examples,
   causing the script to include attachments into the output file.

Definition at line 17 of file package.py.


Constructor & Destructor Documentation

def MoinMoin.script.export.package.PluginScript.__init__ (   self,
  argv = None,
  def_values = None 
)

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 50 of file package.py.

00050 
00051     def __init__(self, argv=None, def_values=None):
00052         script.MoinScript.__init__(self, argv, def_values)
00053         self.parser.add_option(
00054             "-p", "--pages", dest="pages",
00055             help="List of pages to package. Can be regular expressions, comma seperated lists, or a lone * for everything."
00056         )
00057         self.parser.add_option(
00058             "-a", "--include_attachments", action="store_true", dest="attachment",
00059             help="Include attachments from each page"
00060         )
00061         self.parser.add_option(
00062             "-o", "--output", dest="output",
00063             help="Output file for the package."
00064         )
00065         self.parser.add_option(
00066             "-s", "--search", dest="search",
00067             help="Search string to match."
00068         )
00069 
00070         self.parser.add_option(
00071             "-u", "--user", dest="package_user",
00072             help="User as whom the package operation will be performed as. "
00073             )


Member Function Documentation

def MoinMoin.script.MoinScript.init_request (   self) [inherited]
create request 

Definition at line 174 of file __init__.py.

00174 
00175     def init_request(self):
00176         """ create request """
00177         from MoinMoin.web.contexts import ScriptContext
00178         url = self.options.wiki_url or None
00179         self.request = ScriptContext(url, self.options.page)

Here is the caller graph for this function:

def MoinMoin.script.Script.logRuntime (   self) [inherited]
Print the total command run time. 

Definition at line 148 of file __init__.py.

00148 
00149     def logRuntime(self):
00150         """ Print the total command run time. """
00151         if self.options.show_timing:
00152             log("Needed %.3f secs." % (time.clock() - _start_time, ))
00153 

Here is the call graph for this function:

moin-package's main code. 

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 74 of file package.py.

00074 
00075     def mainloop(self):
00076         """ moin-package's main code. """
00077 
00078         # Initalize request
00079         self.init_request()
00080         request = self.request
00081         _ = self.request.getText
00082 
00083         # Check our command line args
00084         if self.options.pages and self.options.search:
00085             script.fatal(_("Options --pages and --search are mutually exclusive!"))
00086         elif not self.options.output:
00087             script.fatal(_("You must specify an output file!"))
00088         elif not self.options.pages and not self.options.search:
00089             script.log(_("No pages specified using --pages or --search, assuming full package."))
00090 
00091         include_attachments = self.options.attachment or False
00092         if include_attachments:
00093             script.log(_("All attachments included into the package."))
00094 
00095         # Sanity checks
00096         if os.path.exists(self.options.output):
00097             script.fatal(_("Output file already exists! Cowardly refusing to continue!"))
00098 
00099         # Check for user
00100         if self.options.package_user:
00101             request.user = user.User(request, name=self.options.package_user)
00102 
00103         # Import PackagePages here, as we now have an initalized request.
00104         from MoinMoin.action.PackagePages import PackagePages
00105 
00106         # Perform actual packaging.
00107         package = PackagePages(request.rootpage.page_name, request)
00108         packageoutput = open(self.options.output, "wb")
00109         if self.options.search:
00110             packagedata = package.collectpackage(package.searchpackage(request,
00111                                                                        self.options.search), packageoutput,
00112                                                                        include_attachments=include_attachments)
00113         elif self.options.pages:
00114             packagedata = package.collectpackage(self.options.pages.split(","), packageoutput, include_attachments=include_attachments)
00115         else:
00116             packagedata = package.collectpackage(request.rootpage.getPageList(
00117                                 include_underlay=False,
00118                                 filter=lambda name: not wikiutil.isSystemPage(request, name)),
00119                                 packageoutput, include_attachments=include_attachments)
00120         if packagedata:
00121             script.fatal(packagedata)
00122 

Here is the call graph for this function:

def MoinMoin.script.Script.run (   self,
  showtime = 1 
) [inherited]
Run the main function of a command. 

Definition at line 130 of file __init__.py.

00130 
00131     def run(self, showtime=1):
00132         """ Run the main function of a command. """
00133         global flag_quiet
00134         try:
00135             try:
00136                 self.options, self.args = self.parser.parse_args(self.argv)
00137                 flag_quiet = self.options.quiet
00138                 # ToDo check if we need to initialize request (self.init_request())
00139                 self.mainloop()
00140             except KeyboardInterrupt:
00141                 log("*** Interrupted by user!")
00142             except SystemExit:
00143                 showtime = 0
00144                 raise
00145         finally:
00146             if showtime:
00147                 self.logRuntime()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 135 of file __init__.py.

Definition at line 102 of file __init__.py.

Definition at line 113 of file __init__.py.

Definition at line 178 of file __init__.py.


The documentation for this class was generated from the following file: