hgweb: break templater -> templater circular reference
The problem were some functions passed in the "defaults" argument
during the templater creation which use "self.t" directly. This
creates the cycle:
hgweb object
-> templater object
-> defaults dict
-> footer function
-> hgweb object
Instead of completely avoding the cycle, we break it after using
the templater.
--- a/mercurial/hgweb/hgweb_mod.py Sun Mar 18 20:39:25 2007 +0100
+++ b/mercurial/hgweb/hgweb_mod.py Mon Mar 19 19:07:35 2007 -0300
@@ -806,19 +806,22 @@
"sessionvars": sessionvars
})
- if not req.form.has_key('cmd'):
- req.form['cmd'] = [self.t.cache['default']]
+ try:
+ if not req.form.has_key('cmd'):
+ req.form['cmd'] = [self.t.cache['default']]
- cmd = req.form['cmd'][0]
+ cmd = req.form['cmd'][0]
- method = getattr(self, 'do_' + cmd, None)
- if method:
- try:
- method(req)
- except (hg.RepoError, revlog.RevlogError), inst:
- req.write(self.t("error", error=str(inst)))
- else:
- req.write(self.t("error", error='No such method: ' + cmd))
+ method = getattr(self, 'do_' + cmd, None)
+ if method:
+ try:
+ method(req)
+ except (hg.RepoError, revlog.RevlogError), inst:
+ req.write(self.t("error", error=str(inst)))
+ else:
+ req.write(self.t("error", error='No such method: ' + cmd))
+ finally:
+ self.t = None
def changectx(self, req):
if req.form.has_key('node'):