Mercurial > moin > 1.9
changeset 1768:5215c7e04a61
merge main
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Tue, 30 Jan 2007 23:07:33 +0100 |
parents | df2e76ac7dee (current diff) d276e28dfc10 (diff) |
children | 2778c4ce1ea4 |
files | |
diffstat | 3 files changed, 30 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/Page.py Tue Jan 30 23:06:56 2007 +0100 +++ b/MoinMoin/Page.py Tue Jan 30 23:07:33 2007 +0100 @@ -5,6 +5,7 @@ @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>, 2005-2006 by MoinMoin:ThomasWaldmann, 2006 by MoinMoin:FlorianFesti. + 2007 by ReimarBauer @license: GNU GPL, see COPYING for details. """ @@ -859,6 +860,30 @@ request.emit_http_headers() request.write(text) + + def save_raw(self): + """ Output the raw page data to a file """ + request = self.request + request.setHttpHeader("Content-type: text/plain; charset=%s" % config.charset) + if self.exists() and request.user.may.read(self.page_name): + # use the correct last-modified value from the on-disk file + # to ensure cacheability where supported. Because we are sending + # RAW (file) content, the file mtime is correct as Last-Modified header. + request.setHttpHeader("Status: 200 OK") + request.setHttpHeader("Last-Modified: %s" % timefuncs.formathttpdate(os.path.getmtime(self._text_filename()))) + file_name = "%s.txt" % self.page_name + text = self.get_raw_body() + text = self.encodeTextMimeType(text) + request.setHttpHeader("Content-Length: %d" % len(text)) + request.setHttpHeader('Content-Disposition: %s; filename="%s"' % ('attachment', file_name)) + else: + request.setHttpHeader('Status: 404 NOTFOUND') + text = u"Page %s not found." % self.page_name + + request.emit_http_headers() + request.write(text) + + def send_page(self, request, msg=None, **keywords): """ Output the formatted page.
--- a/MoinMoin/action/Save.py Tue Jan 30 23:06:56 2007 +0100 +++ b/MoinMoin/action/Save.py Tue Jan 30 23:07:33 2007 +0100 @@ -1,46 +1,17 @@ # -*- coding: iso-8859-1 -*- """ - MoinMoin - Action macro for saving a page without processing instructions + MoinMoin - Action macro for saving a page MODIFICATION HISTORY: @copyright: 2007 by Reimar Bauer @license: GNU GPL, see COPYING for details. """ -import os + from MoinMoin.Page import Page -from MoinMoin.action import AttachFile -from MoinMoin.util import timefuncs def execute(pagename, request): - _ = request.getText - thispage = Page(request, pagename) - msg = _("You are not allowed to view this page.") if request.user.may.read(pagename): - attachment_path = AttachFile.getAttachDir(request, pagename, create=1) - timestamp = timefuncs.formathttpdate(int(os.path.getmtime(attachment_path))) - file = "%s.txt" % pagename - raw = Page(request, pagename).get_raw_body() - lines = raw.split('\n') - result = [] - for line in lines: - is_good = True - for pi in ("#format", "#refresh", "#redirect", "#deprecated", - "#pragma", "#form", "#acl", "#language"): - if line.lower().startswith(pi): - is_good = False - break - if is_good: - result.append(line) - result = '\n'.join(result) + thispage = Page(request, pagename) + thispage.save_raw() - content_type = "text/plain" - request.emit_http_headers([ - 'Content-Type: %s' % content_type, - 'Last-Modified: %s' % timestamp, - 'Content-Length: %d' % len(result), - 'Content-Disposition: %s; filename="%s"' % ('attachment', file), - ]) - request.write(result) - return thispage.send_page(request, msg=msg) -
--- a/MoinMoin/wikiutil.py Tue Jan 30 23:06:56 2007 +0100 +++ b/MoinMoin/wikiutil.py Tue Jan 30 23:07:33 2007 +0100 @@ -3,7 +3,7 @@ MoinMoin - Wiki Utility Functions @copyright: 2000 - 2004 by Jürgen Hermann <jh@web.de> - @copyright: 2007 Reimar Bauer + 2007 by Reimar Bauer @license: GNU GPL, see COPYING for details. """