230 | | response = self.handler(environ) |
231 | | except TemplateDoesNotExist, e: |
232 | | # If the view raises an exception, Django will attempt to show |
233 | | # the 500.html template. If that template is not available, |
234 | | # we should ignore the error in favor of re-raising the |
235 | | # underlying exception that caused the 500 error. Any other |
236 | | # template found to be missing during view error handling |
237 | | # should be reported as-is. |
238 | | if e.args != ('500.html',): |
239 | | raise |
240 | | |
241 | | # Look for a signalled exception, clear the current context |
242 | | # exception data, then re-raise the signalled exception. |
243 | | # Also make sure that the signalled exception is cleared from |
244 | | # the local cache! |
245 | | if self.exc_info: |
246 | | exc_info = self.exc_info |
247 | | self.exc_info = None |
248 | | raise exc_info[1], None, exc_info[2] |
249 | | |
250 | | # Save the client and request that stimulated the response. |
251 | | response.client = self |
252 | | response.request = request |
253 | | |
254 | | # Add any rendered template detail to the response. |
255 | | # If there was only one template rendered (the most likely case), |
256 | | # flatten the list to a single element. |
257 | | for detail in ('template', 'context'): |
258 | | if data.get(detail): |
259 | | if len(data[detail]) == 1: |
260 | | setattr(response, detail, data[detail][0]); |
| 228 | |
| 229 | try: |
| 230 | response = self.handler(environ) |
| 231 | except TemplateDoesNotExist, e: |
| 232 | # If the view raises an exception, Django will attempt to show |
| 233 | # the 500.html template. If that template is not available, |
| 234 | # we should ignore the error in favor of re-raising the |
| 235 | # underlying exception that caused the 500 error. Any other |
| 236 | # template found to be missing during view error handling |
| 237 | # should be reported as-is. |
| 238 | if e.args != ('500.html',): |
| 239 | raise |
| 240 | |
| 241 | # Look for a signalled exception, clear the current context |
| 242 | # exception data, then re-raise the signalled exception. |
| 243 | # Also make sure that the signalled exception is cleared from |
| 244 | # the local cache! |
| 245 | if self.exc_info: |
| 246 | exc_info = self.exc_info |
| 247 | self.exc_info = None |
| 248 | raise exc_info[1], None, exc_info[2] |
| 249 | |
| 250 | # Save the client and request that stimulated the response. |
| 251 | response.client = self |
| 252 | response.request = request |
| 253 | |
| 254 | # Add any rendered template detail to the response. |
| 255 | # If there was only one template rendered (the most likely case), |
| 256 | # flatten the list to a single element. |
| 257 | for detail in ('template', 'context'): |
| 258 | if data.get(detail): |
| 259 | if len(data[detail]) == 1: |
| 260 | setattr(response, detail, data[detail][0]); |
| 261 | else: |
| 262 | setattr(response, detail, data[detail]) |