set gettext.js's charset to utf-8 in the content-type header

don't use NamedTemporaryFile for the Upload resource as the delete kw 
arg was only added in py2.6
This commit is contained in:
Damien Churchill 2009-04-08 08:22:02 +00:00
parent 891b1120a3
commit 855385227a
1 changed files with 10 additions and 8 deletions

View File

@ -86,7 +86,7 @@ def rpath(path):
class GetText(resource.Resource): class GetText(resource.Resource):
def render(self, request): def render(self, request):
request.setHeader("content-type", "text/javascript") request.setHeader("content-type", "text/javascript; encoding=utf-8")
template = Template(filename=rpath("gettext.js")) template = Template(filename=rpath("gettext.js"))
return template.render() return template.render()
@ -116,10 +116,10 @@ class Upload(resource.Resource):
filenames = [] filenames = []
for upload in request.args.get("file"): for upload in request.args.get("file"):
f = tempfile.NamedTemporaryFile(dir=tempdir, delete=False) fd, fn = tempfile.mkstemp('.torrent', dir=tempdir)
f.write(upload) os.write(fd, upload)
filenames.append(f.name) os.close(fd)
f.close() filenames.append(fn)
request.setHeader("content-type", "text/plain") request.setHeader("content-type", "text/plain")
request.setResponseCode(http.OK) request.setResponseCode(http.OK)
return "\n".join(filenames) return "\n".join(filenames)
@ -250,10 +250,12 @@ class DelugeWeb(component.Component):
SetConsoleCtrlHandler(win_handler) SetConsoleCtrlHandler(win_handler)
def start(self): def start(self):
print "Starting server in PID %s." % os.getpid() print "%s %s." % (_("Starting server in PID"), os.getpid())
reactor.listenTCP(self.port, self.site) reactor.listenTCP(self.port, self.site)
print "serving on 0.0.0.0:%(port)s view at http://127.0.0.1:%(port)s" % { print "%(serve)s 0.0.0.0:%(port)s %(view)s http://127.0.0.1:%(port)s" % {
"port": self.port "port": self.port,
"serve": _("serving on"),
"view": _("view at")
} }
reactor.run() reactor.run()