comparison MoinMoin/action/AttachFile.py @ 101:2202f548cbb0

use own urllib wrapper, see wikiutil imported from: moin--main--1.5--patch-103
author Thomas Waldmann <tw@waldmann-edv.de>
date Sat, 15 Oct 2005 16:56:39 +0000
parents 99f0d19d0285
children a54cebaab73e
comparison
equal deleted inserted replaced
100:9aa2836c997b 101:2202f548cbb0
23 @copyright: 2005 R. Bauer 23 @copyright: 2005 R. Bauer
24 @copyright: 2005 MoinMoin:AlexanderSchremmer 24 @copyright: 2005 MoinMoin:AlexanderSchremmer
25 @license: GNU GPL, see COPYING for details. 25 @license: GNU GPL, see COPYING for details.
26 """ 26 """
27 27
28 import os, mimetypes, time, urllib, zipfile 28 import os, mimetypes, time, zipfile
29 from MoinMoin import config, user, util, wikiutil, packages 29 from MoinMoin import config, user, util, wikiutil, packages
30 from MoinMoin.Page import Page 30 from MoinMoin.Page import Page
31 from MoinMoin.util import MoinMoinNoFooter, filesys, web 31 from MoinMoin.util import MoinMoinNoFooter, filesys, web
32 32
33 action_name = __name__.split('.')[-1] 33 action_name = __name__.split('.')[-1]
81 except IOError: 81 except IOError:
82 pass 82 pass
83 83
84 url = "%s/%s/attachments/%s%s" % ( 84 url = "%s/%s/attachments/%s%s" % (
85 request.cfg.attachments['url'], wikiutil.quoteWikinameFS(pagename), 85 request.cfg.attachments['url'], wikiutil.quoteWikinameFS(pagename),
86 urllib.quote(filename.encode(config.charset)), timestamp) 86 wikiutil.url_quote(filename), timestamp)
87 else: 87 else:
88 # send file via CGI 88 # send file via CGI
89 url = "%s/%s?action=%s&do=get&target=%s" % ( 89 url = "%s/%s?action=%s&do=get&target=%s" % (
90 request.getScriptname(), wikiutil.quoteWikinameURL(pagename), 90 request.getScriptname(), wikiutil.quoteWikinameURL(pagename),
91 action_name, urllib.quote_plus(filename.encode(config.charset))) 91 action_name, wikiutil.url_quote_plus(filename))
92 if escaped: 92 if escaped:
93 url = wikiutil.escape(url) 93 url = wikiutil.escape(url)
94 return url 94 return url
95 95
96 def getIndicator(request, pagename): 96 def getIndicator(request, pagename):
145 145
146 `action` should be "ATTNEW" or "ATTDEL" 146 `action` should be "ATTNEW" or "ATTDEL"
147 """ 147 """
148 from MoinMoin.logfile import editlog 148 from MoinMoin.logfile import editlog
149 t = wikiutil.timestamp2version(time.time()) 149 t = wikiutil.timestamp2version(time.time())
150 # urllib always return ascii 150 fname = wikiutil.url_quote(filename, want_unicode=True)
151 fname = unicode(urllib.quote(filename.encode(config.charset)))
152 151
153 # TODO: for now we simply write 2 logs, maybe better use some multilog stuff 152 # TODO: for now we simply write 2 logs, maybe better use some multilog stuff
154 # Write to global log 153 # Write to global log
155 log = editlog.EditLog(request) 154 log = editlog.EditLog(request)
156 log.add(request, t, 99999999, action, pagename, request.remote_addr, fname) 155 log.add(request, t, 99999999, action, pagename, request.remote_addr, fname)
212 fsize = float(os.stat(os.path.join(attach_dir,file).encode(config.charset))[6]) # in byte 211 fsize = float(os.stat(os.path.join(attach_dir,file).encode(config.charset))[6]) # in byte
213 fsize = "%.1f" % (fsize / 1024) 212 fsize = "%.1f" % (fsize / 1024)
214 baseurl = request.getScriptname() 213 baseurl = request.getScriptname()
215 action = action_name 214 action = action_name
216 urlpagename = wikiutil.quoteWikinameURL(pagename) 215 urlpagename = wikiutil.quoteWikinameURL(pagename)
217 urlfile = urllib.quote_plus(file.encode(config.charset)) 216 urlfile = wikiutil.url_quote_plus(file)
218 217
219 base, ext = os.path.splitext(file) 218 base, ext = os.path.splitext(file)
220 get_url = getAttachUrl(pagename, file, request, escaped=1) 219 get_url = getAttachUrl(pagename, file, request, escaped=1)
221 parmdict = {'baseurl': baseurl, 'urlpagename': urlpagename, 'action': action, 220 parmdict = {'baseurl': baseurl, 'urlpagename': urlpagename, 'action': action,
222 'urlfile': urlfile, 'label_del': label_del, 221 'urlfile': urlfile, 'label_del': label_del,
288 pagename_quoted = wikiutil.quoteWikinameURL(pagename) 287 pagename_quoted = wikiutil.quoteWikinameURL(pagename)
289 288
290 for file in files: 289 for file in files:
291 url = "%s/%s?action=%s&do=view&target=%s" % ( 290 url = "%s/%s?action=%s&do=view&target=%s" % (
292 scriptName, pagename_quoted, 291 scriptName, pagename_quoted,
293 action_name, urllib.quote_plus(file.encode(config.charset))) 292 action_name, wikiutil.url_quote_plus(file))
294 293
295 request.write(u'<link rel="Appendix" title="%s" href="%s">\n' % ( 294 request.write(u'<link rel="Appendix" title="%s" href="%s">\n' % (
296 wikiutil.escape(file), wikiutil.escape(url))) 295 wikiutil.escape(file), wikiutil.escape(url)))
297 296
298 297