首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >satchmo无法处理500错误

satchmo无法处理500错误
EN

Stack Overflow用户
提问于 2010-01-01 12:24:17
回答 1查看 517关注 0票数 1

如果产品的数量是Unicode字符,我将在/ UnicodeEncodeError /处获得添加。当我设置DEBUG = False时,satchmo不能处理500错误,它不能返回HttpResponse对象,但是handler404是正常的。我在apache错误日志中找到了以下内容。

代码语言:javascript
复制
[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124] mod_wsgi
(pid=10523): Exception occurred processing WSGI script '/etc/httpd/
conf.d/myshop.wsgi'.

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124] Traceback
(most recent call last):

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
etc/httpd/conf.d/myshop.wsgi", line 34, in application[Thu Dec 31
23:05:31 2009] [error] [client 192.168.123.124]     return _application
(environ, start_response)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 241, in __call__

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]
response = self.get_response(request)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/core/handlers/
base.py", line 134, in get_response

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
self.handle_uncaught_exception(request, resolver, exc_info)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/core/handlers/
base.py", line 166, in handle_uncaught_exception

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
callback(request, **param_dict)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/views/
defaults.py", line 24, in server_error

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
http.HttpResponseServerError(t.render(Context({})))

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 178, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
self.nodelist.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 779, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]
bits.append(self.render_node(node, context))

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 792, in render_node

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
node.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
loader_tags.py", line 97, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
compiled_parent.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 178, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
self.nodelist.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 779, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]
bits.append(self.render_node(node, context))

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 792, in render_node

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
node.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
loader_tags.py", line 24, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     result
= self.nodelist.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 779, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]
bits.append(self.render_node(node, context))

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 792, in render_node

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
node.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
loader_tags.py", line 24, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     result
= self.nodelist.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 779, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]
bits.append(self.render_node(node, context))

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 792, in render_node

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     return
node.render(context)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
__init__.py", line 936, in render

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     dict =
func(*args)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/Satchmo-1.0_pre-py2.5.egg/
satchmo_store/shop/templatetags/satchmo_util.py", line 179, in
satchmo_language_selection_form

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]
request = context['request']

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]   File "/
opt/python-2.5.4/lib/python2.5/site-packages/django/template/
context.py", line 44, in __getitem__

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124]     raise
KeyError(key)

[Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124] KeyError:
'request' 

下面是500.html:

代码语言:javascript
复制
{% extends "base.html" %}
{% load i18n %}

{% block navbar %}
   <li class="first"><a href="{{ shop_base }}/">{% trans "Home" %}</a></li>
{% endblock %}

{% block content %}

    <h3>{% trans "Error" %}</h3>
    <h4>{% trans "There was an error with the store.  The admin has been notified." %}</h4>

{% endblock %}

下面是base.html:

代码语言:javascript
复制
{% load i18n satchmo_category satchmo_google satchmo_util satchmo_currency satchmo_discounts app_plugins normalize_decimal %}
{% block doctype %}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
{% endblock %}
<head>
    {% block extra-head %}{% endblock %}
    {% block stylesheet %}<link rel="stylesheet" href="{{ media_url }}css/style.css" />{% endblock %}
    <title>{% block title %}{{ shop_name }}{% if pagetitle %}: {{ pagetitle }}{% endif %}{% endblock %}</title>
    {% plugin_point "page_head" %}
</head>
{% block body %}
contents
{% endblock %}
</html>

为什么django不能处理500错误页面?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-01-02 08:46:16

作者:Django's documentation

默认的500视图不会向此模板传递任何变量,并使用空上下文呈现,以减少出现其他错误的机会

我认为你应该对你的500.html保持同样的方法,通过而不是扩展base.html,甚至不是引用i18n,而是让它尽可能简单的保持。

当您遇到服务器错误时,请考虑一下上下文:有些地方出错了,但您不知道是什么原因。您甚至可能处于不满足所有常见前提条件的情况下,因此您应该尽可能简单地维护页面。

就我个人而言,我甚至避免使用图像,只依赖于一些ASCII艺术:-)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1987867

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档