From f77703d25056236d027a1a61bf63fab3a7c1b2c2 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 28 May 2011 00:13:06 -0400 Subject: horrid workaround for no app_iter initialized --- pyramid/exceptions.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pyramid/exceptions.py b/pyramid/exceptions.py index 60e3c7b9b..e9718c6ab 100644 --- a/pyramid/exceptions.py +++ b/pyramid/exceptions.py @@ -84,6 +84,12 @@ class HTTPNotFound(_HTTPNotFound): _HTTPNotFound.__init__(self, detail=detail, headers=headers, comment=comment, body_template=body_template, **kw) + if not ('body' in kw or 'app_iter' in kw): + if not self.empty_body: + body = self.html_body(self.environ) + if isinstance(body, unicode): + body = body.encode(self.charset) + self.body = body class HTTPForbidden(_HTTPForbidden): """ @@ -114,6 +120,12 @@ class HTTPForbidden(_HTTPForbidden): _HTTPForbidden.__init__(self, detail=detail, headers=headers, comment=comment, body_template=body_template, **kw) + if not ('body' in kw or 'app_iter' in kw): + if not self.empty_body: + body = self.html_body(self.environ) + if isinstance(body, unicode): + body = body.encode(self.charset) + self.body = body NotFound = HTTPNotFound # bw compat Forbidden = HTTPForbidden # bw compat -- cgit v1.2.3