8000 horrid workaround for no app_iter initialized · alex-python/pyramid@f77703d · GitHub
[go: up one dir, main page]

Skip to content

Commit f77703d

Browse files
committed
horrid workaround for no app_iter initialized
1 parent 8c2a9e6 commit f77703d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pyramid/exceptions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ def __init__(self, detail=None, headers=None, comment=None,
8484
_HTTPNotFound.__init__(self, detail=detail, headers=headers,
8585
comment=comment, body_template=body_template,
8686
**kw)
87+
if not ('body' in kw or 'app_iter' in kw):
88+
if not self.empty_body:
89+
body = self.html_body(self.environ)
90+
if isinstance(body, unicode):
91+
body = body.encode(self.charset)
92+
self.body = body
8793

8894
class HTTPForbidden(_HTTPForbidden):
8995
"""
@@ -114,6 +120,12 @@ def __init__(self, detail=None, headers=None, comment=None,
114120
_HTTPForbidden.__init__(self, detail=detail, headers=headers,
115121
comment=comment, body_template=body_template,
116122
**kw)
123+
if not ('body' in kw or 'app_iter' in kw):
124+
if not self.empty_body:
125+
body = self.html_body(self.environ)
126+
if isinstance(body, unicode):
127+
body = body.encode(self.charset)
128+
self.body = body
117129

118130
NotFound = HTTPNotFound # bw compat
119131
Forbidden = HTTPForbidden # bw compat

0 commit comments

Comments
 (0)
0