annotate MoinMoin/action/PackagePages.py @ 5522:879674c9320a

AttachFile: add ticketing for all operations that do modifications Tickets for upload (POST), also for every (GET) URL except do=get and do=view. Avoid KeyError if there is no ticket (was a minor issues, because there has to be one). Use the same i18n string for all "Please use the interactive user interface" messages.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 08 Feb 2010 18:56:07 +0100
parents d54e233a8784
children 62177a952833
rev   line source
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
2 """
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
3 MoinMoin - PackagePages action
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
4
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
5 This action allows you to package pages.
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
6
610
8dac4b68072b refactor RenamePage and DeletePage action to use ActionBase base class, move rename page code to PageEditor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 566
diff changeset
7 TODO: use ActionBase class
8dac4b68072b refactor RenamePage and DeletePage action to use ActionBase base class, move rename page code to PageEditor
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 566
diff changeset
8
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
9 @copyright: 2005 MoinMoin:AlexanderSchremmer
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
11 """
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
12
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
13 import os
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
14 import zipfile
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
15 from datetime import datetime
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
16
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
17 from MoinMoin import wikiutil, config, user
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
18 from MoinMoin.Page import Page
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
19 from MoinMoin.action.AttachFile import _addLogEntry
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
20 from MoinMoin.packages import MOIN_PACKAGE_FILE, packLine, unpackLine
1718
1d0663c1c44f PackagePages:added storing of attachments, form pagename text field gots current page name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1317
diff changeset
21 from MoinMoin.action import AttachFile
1d0663c1c44f PackagePages:added storing of attachments, form pagename text field gots current page name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1317
diff changeset
22 from MoinMoin.action.AttachFile import _get_files
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
23 from MoinMoin.search import searchPages
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
24
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
25 class ActionError(Exception):
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
26 pass
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
27
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
28 class PackagePages:
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
29 def __init__(self, pagename, request):
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
30 self.request = request
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
31 self.pagename = pagename
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
32 self.page = Page(request, pagename)
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
33
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
34 def allowed(self):
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
35 """ Check if user is allowed to do this. """
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
36 may = self.request.user.may
183
b4c7c65b6af0 PackagePages bugfix
Thomas Waldmann <tw@waldmann-edv.de>
parents: 112
diff changeset
37 return (not self.__class__.__name__ in self.request.cfg.actions_excluded and
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
38 may.write(self.pagename))
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
39
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
40 def render(self):
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
41 """ Render action
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
42
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
43 This action returns a wiki page with optional message, or
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
44 redirects to new page.
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
45 """
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
46 _ = self.request.getText
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
47 form = self.request.form
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
48
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
49 if 'cancel' in form:
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
50 # User canceled
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1744
diff changeset
51 return self.page.send_page()
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
52
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
53 try:
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
54 if not self.allowed():
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
55 self.request.theme.add_msg(_('You are not allowed to edit this page.'), "error")
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
56 raise ActionError
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
57 elif not self.page.exists():
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
58 self.request.theme.add_msg(_('This page is already deleted or was never created!'))
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
59 raise ActionError
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
60
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
61 self.package()
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
62 except ActionError, e:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
63 return self.page.send_page()
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
64
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
65 def package(self):
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
66 """ Calls collectpackage() with the arguments specified. """
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
67 _ = self.request.getText
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
68 form = self.request.form
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
69
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
70 # Get new name from form and normalize.
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
71 pagelist = form.get('pagelist', [u''])[0]
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
72 packagename = form.get('packagename', [u''])[0]
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
73 include_attachments = form.get('include_attachments', [False])[0]
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
74
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
75 if not form.get('submit', [None])[0]:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
76 self.request.theme.add_msg(self.makeform(), "dialog")
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
77 raise ActionError
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
78
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
79 target = wikiutil.taintfilename(packagename)
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
80
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
81 if not target:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
82 self.request.theme.add_msg(self.makeform(_('Invalid filename "%s"!') % wikiutil.escape(packagename)), "error")
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
83 raise ActionError
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
84
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
85 # get directory, and possibly create it
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
86 attach_dir = Page(self.request, self.page.page_name).getPagePath("attachments", check_create=1)
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
87 fpath = os.path.join(attach_dir, target).encode(config.charset)
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
88 if os.path.exists(fpath):
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
89 self.request.theme.add_msg(_("Attachment '%(target)s' (remote name '%(filename)s') already exists.") % {
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
90 'target': wikiutil.escape(target), 'filename': wikiutil.escape(target)}, "error")
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
91 raise ActionError
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
92
3213
6162f334bd5a fix some more minor problems find by pydev (unused/double imports, wrong indentation, ...)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3211
diff changeset
93 # Generate a package
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
94 output = open(fpath, "wb")
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
95 package = self.collectpackage(unpackLine(pagelist, ","), output, target, include_attachments)
1718
1d0663c1c44f PackagePages:added storing of attachments, form pagename text field gots current page name
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 1317
diff changeset
96
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
97 if package:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
98 self.request.theme.add_msg(self.makeform(), "dialog")
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
99 raise ActionError
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
100
522
3ea8fd50dd53 use correct pagename for PackagePages logging
Thomas Waldmann <tw@waldmann-edv.de>
parents: 183
diff changeset
101 _addLogEntry(self.request, 'ATTNEW', self.pagename, target)
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
102
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
103 self.request.theme.add_msg(_("Created the package %s containing the pages %s.") % (wikiutil.escape(target), wikiutil.escape(pagelist)))
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
104 raise ActionError
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
105
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
106 def makeform(self, error=""):
3475
44a2f2f0d755 MoinMoin.action.PackagePages: fixed doc string
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3474
diff changeset
107 """ Display a package page form
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
108
3475
44a2f2f0d755 MoinMoin.action.PackagePages: fixed doc string
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3474
diff changeset
109 The form might contain an error that happened when package file was not given.
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
110 """
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
111 from MoinMoin.widget.dialog import Dialog
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
112 _ = self.request.getText
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
113
3474
b485c2b6b2b9 MoinMoin.action.PackagePages: shows only class error on error
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3273
diff changeset
114 if error:
b485c2b6b2b9 MoinMoin.action.PackagePages: shows only class error on error
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3273
diff changeset
115 error = u'<p class="error">%s</p>\n' % error
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
116
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
117 d = {
3040
8608b258f8e6 bug fix of MoinMoinBugs/MoveAttachmentNotWorkingWithModPython (thanks to Boleslaw Kulbabinski) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
118 'baseurl': self.request.getScriptname(),
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
119 'error': error,
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
120 'action': self.__class__.__name__,
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3213
diff changeset
121 'pagename': wikiutil.escape(self.pagename, True),
3040
8608b258f8e6 bug fix of MoinMoinBugs/MoveAttachmentNotWorkingWithModPython (thanks to Boleslaw Kulbabinski) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
122 'pagename_quoted': wikiutil.quoteWikinameURL(self.pagename),
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
123 'include_attachments_label': _('Include all attachments?'),
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
124 'package': _('Package pages'),
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
125 'cancel': _('Cancel'),
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
126 'newname_label': _("Package name"),
566
f52e03acf42a Changed i18n string in PackagePages
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 522
diff changeset
127 'list_label': _("List of page names - separated by a comma"),
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
128 }
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
129 form = '''
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
130 %(error)s
3040
8608b258f8e6 bug fix of MoinMoinBugs/MoveAttachmentNotWorkingWithModPython (thanks to Boleslaw Kulbabinski) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
131 <form method="post" action="%(baseurl)s/%(pagename_quoted)s">
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
132 <input type="hidden" name="action" value="%(action)s">
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
133 <table>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
134 <tr>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
135 <td class="label"><label>%(newname_label)s</label></td>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
136 <td class="content">
2708
5092edd82058 bug fix for non css browsers like w3m: for input fields set size of textarea and text to cols="80"
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2286
diff changeset
137 <input type="text" name="packagename" value="package.zip" size="80">
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
138 </td>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
139 </tr>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
140 <tr>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
141 <td class="label"><label>%(list_label)s</label></td>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
142 <td class="content">
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3213
diff changeset
143 <input type="text" name="pagelist" size="80" maxlength="200" value="%(pagename)s">
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
144 </td>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
145 </tr>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
146 <tr>
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
147 <td class="label">
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
148 %(include_attachments_label)s<input type="checkbox" name="include_attachments" value="0" %(include_attachments_label)s>
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
149 </td>
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
150 </tr>
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
151 <tr>
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
152 <td></td>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
153 <td class="buttons">
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
154 <input type="submit" name="submit" value="%(package)s">
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
155 <input type="submit" name="cancel" value="%(cancel)s">
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
156 </td>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
157 </tr>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
158 </table>
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
159 </form>''' % d
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
160
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
161 return Dialog(self.request, content=form)
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
162
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
163 def searchpackage(self, request, searchkey):
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
164 """ Search MoinMoin for the string specified and return a list of
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
165 matching pages, provided they are not system pages and not
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
166 present in the underlay.
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
167
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
168 @param request: current request
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
169 @param searchkey: string to search for
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
170 @rtype: list
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
171 @return: list of pages matching searchkey
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
172 """
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
173
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
174 pagelist = searchPages(request, searchkey)
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
175
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
176 titles = []
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
177 for title in pagelist.hits:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
178 if not wikiutil.isSystemPage(request, title.page_name) or not title.page.getPageStatus()[0]:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
179 titles.append(title.page_name)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
180 return titles
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
181
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
182 def collectpackage(self, pagelist, fileobject, pkgname="", include_attachments=False):
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
183 """ Expects a list of pages as an argument, and fileobject to be an open
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
184 file object, which a zipfile will get written to.
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
185
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
186 @param pagelist: pages to package
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
187 @param fileobject: open file object to write to
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
188 @param pkgname: optional file name, to prevent self packaging
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
189 @rtype: string or None
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
190 @return: error message, if one happened
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
191 @rtype: boolean
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
192 @param include_attachments: True if you want attachments collected
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
193 """
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
194 _ = self.request.getText
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
195 COMPRESSION_LEVEL = zipfile.ZIP_DEFLATED
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
196
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
197 pages = []
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
198 for pagename in pagelist:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
199 pagename = self.request.normalizePagename(pagename)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
200 if pagename:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
201 page = Page(self.request, pagename)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
202 if page.exists() and self.request.user.may.read(pagename):
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
203 pages.append(page)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
204 if not pages:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
205 return (_('No pages like "%s"!') % wikiutil.escape(pagelist))
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
206
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
207 # Set zipfile output
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
208 zf = zipfile.ZipFile(fileobject, "w", COMPRESSION_LEVEL)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
209
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
210 cnt = 0
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
211 userid = user.getUserIdentification(self.request)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
212 script = [packLine(['MoinMoinPackage', '1']), ]
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
213
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
214 for page in pages:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
215 cnt += 1
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
216 files = _get_files(self.request, page.page_name)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
217 script.append(packLine(["AddRevision", str(cnt), page.page_name, userid, "Created by the PackagePages action."]))
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
218
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
219 timestamp = wikiutil.version2timestamp(page.mtime_usecs())
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
220 zi = zipfile.ZipInfo(filename=str(cnt), date_time=datetime.fromtimestamp(timestamp).timetuple()[:6])
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
221 zi.compress_type = COMPRESSION_LEVEL
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
222 zf.writestr(zi, page.get_raw_body().encode("utf-8"))
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
223 if include_attachments:
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
224 for attname in files:
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
225 if attname != pkgname:
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
226 cnt += 1
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
227 zipname = "%d_attachment" % cnt
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
228 script.append(packLine(["AddAttachment", zipname, attname, page.page_name, userid, "Created by the PackagePages action."]))
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
229 filename = AttachFile.getFilename(self.request, page.page_name, attname)
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3775
diff changeset
230 zf.write(filename, zipname)
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
231 script += [packLine(['Print', 'Thank you for using PackagePages!'])]
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
232
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
233 zf.writestr(MOIN_PACKAGE_FILE, u"\n".join(script).encode("utf-8"))
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
234 zf.close()
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3040
diff changeset
235
112
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
236 def execute(pagename, request):
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
237 """ Glue code for actions """
902ef76b6e5c Added PackagePages action, really.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
238 PackagePages(pagename, request).render()
949
cbbde07e00c4 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 876
diff changeset
239