2010-01-01 5 views
1

Si la quantité du produit est un caractère Unicode, j'obtiens UnicodeEncodeError à/add /. Lorsque j'ai défini DEBUG = False, le satchmo ne peut pas gérer l'erreur 500, il ne peut pas retourner un objet HttpResponse, mais le gestionnaire 404 est correct. Je trouve ce qui suit dans le journal des erreurs Apache.satchmo ne peut pas gérer l'erreur 500

[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' 

ici est 500.html:

{% 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 %} 

et voici base.html:

{% 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> 

Pourquoi django ne peut pas gérer la page d'erreur 500?

+0

va être un peu difficile à dire, à moins que vous postez le code du gestionnaire vous 500 ... –

+0

@ Daniel Roseman Merci de rappeler – ManofPhysics

+0

Obtenez-vous les mêmes résultats lors de l'exécution sous le serveur de développement? –

Répondre

1

Par Django's documentation,

The default 500 view passes no variables to this template and is rendered with an empty Context to lessen the chance of additional errors

Je pense que vous devez garder la même approche pour votre 500.html, par pas extension base.html et pas référence même i18n, et garder la place qu'il aussi simple que possible.

Considérer le contexte lorsque vous obtenez une erreur de serveur: quelque chose s'est mal passé, et vous ne savez pas quoi. Vous pouvez même être dans une situation où toutes les conditions préalables habituelles ne sont pas remplies, et donc vous devriez maintenir la page aussi simple que possible.
Personnellement, je même éviter les images, en se fondant uniquement sur certains art ASCII :-)

+0

@Roberto Liffredo, merci – ManofPhysics