Mercurial > hg
changeset 6391:a1007f7b9b7b
Backed out changeset d2bb66a8a435 (temporary template compatibility)
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 24 Mar 2008 18:18:39 +0100 |
parents | 67784cb38d58 |
children | 2540521dc7c1 |
files | mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py |
diffstat | 2 files changed, 8 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Thu Mar 27 12:52:41 2008 -0700 +++ b/mercurial/hgweb/hgweb_mod.py Mon Mar 24 18:18:39 2008 +0100 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetypes, re, mimetools, cStringIO +import os, mimetypes, re from mercurial.node import hex, nullid, short from mercurial.repo import RepoError from mercurial import mdiff, ui, hg, util, archival, patch, hook @@ -226,17 +226,8 @@ try: tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=self.encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=self.encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=self.encoding) + ctype = templater.stringify(ctype) if cmd == '': req.form['cmd'] = [tmpl.cache['default']] @@ -291,13 +282,7 @@ # some functions for the templater def header(**map): - header = tmpl('header', encoding=self.encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=self.encoding, **map) def footer(**map): yield tmpl("footer", **map)
--- a/mercurial/hgweb/hgwebdir_mod.py Thu Mar 27 12:52:41 2008 -0700 +++ b/mercurial/hgweb/hgwebdir_mod.py Mon Mar 24 18:18:39 2008 +0100 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetools, cStringIO +import os from mercurial.i18n import gettext as _ from mercurial.repo import RepoError from mercurial import ui, hg, util, templater, templatefilters @@ -81,17 +81,8 @@ virtual = req.env.get("PATH_INFO", "").strip('/') tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=util._encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=util._encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=util._encoding) + ctype = templater.stringify(ctype) # a static file if virtual.startswith('static/') or 'static' in req.form: @@ -255,13 +246,7 @@ def templater(self, req): def header(**map): - header = tmpl('header', encoding=util._encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=util._encoding, **map) def footer(**map): yield tmpl("footer", **map)