Short description
Sometimes it is wanted to package all subpages of given pages too
Be aware that if you have large attachments on pages someone can slow down your server doing lots of packages.
1 diff -r b81376013df9 MoinMoin/action/PackagePages.py
2 --- a/MoinMoin/action/PackagePages.py Sat Jan 26 19:18:41 2008 +0100
3 +++ b/MoinMoin/action/PackagePages.py Mon Jan 28 13:07:08 2008 +0100
4 @@ -7,10 +7,12 @@
5 TODO: use ActionBase class
6
7 @copyright: 2005 MoinMoin:AlexanderSchremmer
8 + 2007-2008 MoinMoin:ReimarBauer
9 @license: GNU GPL, see COPYING for details.
10 """
11
12 import os
13 +import re
14 import zipfile
15 from datetime import datetime
16
17 @@ -69,6 +71,21 @@ class PackagePages:
18 pagelist = form.get('pagelist', [u''])[0]
19 packagename = form.get('packagename', [u''])[0]
20
21 + package_subpages = 0
22 + if 'package_subpages' in form:
23 + try:
24 + package_subpages = int(form['package_subpages'][0])
25 + except:
26 + pass
27 +
28 + if package_subpages:
29 + for pagename in pagelist.split(','):
30 + filterfn = re.compile(ur"^%s/.*$" % re.escape(pagename), re.U).match
31 + subpagenames = self.request.rootpage.getPageList(user='', exists=1, filter=filterfn)
32 + subpages = [pagename for pagename in subpagenames if self.request.user.may.read(pagename)]
33 + if subpages:
34 + pagelist = "%s,%s" % (pagelist, ','.join(subpages))
35 +
36 if not form.get('submit', [None])[0]:
37 raise ActionError(self.makeform())
38
39 @@ -103,13 +120,16 @@ class PackagePages:
40 _ = self.request.getText
41
42 error = u'<p class="error">%s</p>\n' % error
43 -
44 +
45 d = {
46 'baseurl': self.request.getScriptname(),
47 'error': error,
48 'action': self.__class__.__name__,
49 'pagename': wikiutil.escape(self.pagename),
50 'pagename_quoted': wikiutil.quoteWikinameURL(self.pagename),
51 + 'subpages_checked':('', 'checked')[self.request.form.get('subpages_checked', ['0'])[0] == '1'],
52 + 'subpage_label': _('Package all /subpages too?', formatted=False),
53 +
54 'package': _('Package pages', formatted=False),
55 'cancel': _('Cancel', formatted=False),
56 'newname_label': _("Package name", formatted=False),
57 @@ -121,6 +141,8 @@ class PackagePages:
58 <input type="hidden" name="action" value="%(action)s">
59 <table>
60 <tr>
61 + <dd>
62 +%(subpage_label)s<input type="checkbox" name="package_subpages" value="1" %(subpages_checked)s> </dd>
63 <td class="label"><label>%(newname_label)s</label></td>
64 <td class="content">
65 <input type="text" name="packagename" value="package.zip" size="80">
Discussion
Does this patch come with V1.9 ? It seems to be very useful to also package subpages. -- JosefMeier 2009-10-23 08:49:09
besides that it can be usefull we don't have a limitation for the amount of the package. If one is able to do call this many times with much subpages and big attachments the sytem becomes DOSed. I think we have to forward this to 2.0.