Excuse me for the delay... I finally had some time to debug this issue. First, about the problems I was having : I moved my application on another server, using apache+mod_python instead of lighttpd+fastcgi, and all my unicode problems disappeared.
But I made some more tests using a blank project, with a simple test app, and I was able to reproduce the problem. Here what I found (sorry for the long message)... My test project/app is pretty standard, I've only modified DB settings (mysql 4.1.20 database), and added a simple entry in urls.py. Here are the models.py and views.py files : models.py : class TestModel(models.Model): title = models.CharField(max_length=255) def __unicode__(self): return self.title views.py : from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.shortcuts import render_to_response from testproject.testapp.models import TestModel def test(request): item = TestModel(title=u'Événement test') item.save() items = TestModel.objects.all() for item in items: title = item.title return render_to_response('items.html', {'items' : items}) from django import newforms as forms # this form seems important - without it, the error does not happen! class AjouterInvitationForm(forms.Form): partenaires = TestModel.objects.all() choices = [] for part in partenaires: p = (part.id, unicode(part),) choices.append(p) partenaire = forms.ChoiceField(choices=choices) As you can see, all the view does is add an unicode string "Événement" to the DB, then display all the records. There is also a form that get some data from the DB, and that's what seem to cause the problem. So, using fastcgi, I get an error only about 1 out of 10-15 page loads. Also, the exception get "eaten" by django/core/urlresolvers.py (line 255), so I commented the try/except statements, so I could see the real exception : #try: self._urlconf_module = __import__(self.urlconf_name, {}, {}, ['']) #except Exception, e: # # Either an invalid urlconf_name, such as "foo.bar.", or some # # kind of problem during the actual import. # raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e) Now here is the stack trace, after modifying django's urlresolvers.py : Unicode error hint The string that could not be encoded/decoded was: �v�neme Traceback: File "/usr/local/lib/python2.4/site-packages/django/core/handlers/ base.py" in get_response 73. callback, callback_args, callback_kwargs = resolver.resolve(request.path) File "/usr/local/lib/python2.4/site-packages/django/core/ urlresolvers.py" in resolve 231. for pattern in self.urlconf_module.urlpatterns: File "/usr/local/lib/python2.4/site-packages/django/core/ urlresolvers.py" in _get_urlconf_module 251. self._urlconf_module = __import__(self.urlconf_name, {}, {}, ['']) File "/home/jphoude/testproject/../testproject/urls.py" in ? 2. from testproject.testapp import views File "/home/jphoude/testproject/../testproject/testapp/views.py" in ? 19. class AjouterInvitationForm(forms.Form): File "/home/jphoude/testproject/../testproject/testapp/views.py" in AjouterInvitationForm 22. for part in partenaires: File "/usr/local/lib/python2.4/site-packages/django/db/models/ query.py" in __iter__ 114. return iter(self._get_data()) File "/usr/local/lib/python2.4/site-packages/django/db/models/ query.py" in _get_data 483. self._result_cache = list(self.iterator()) File "/usr/local/lib/python2.4/site-packages/django/db/models/ query.py" in iterator 189. cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File "/usr/local/lib/python2.4/site-packages/django/db/backends/ util.py" in execute 18. return self.cursor.execute(sql, params) File "/usr/local/lib/python2.4/site-packages/MySQL_python-1.2.2-py2.4- linux-i686.egg/MySQLdb/cursors.py" in execute 166. self.errorhandler(self, exc, value) File "/usr/local/lib/python2.4/site-packages/MySQL_python-1.2.2-py2.4- linux-i686.egg/MySQLdb/connections.py" in defaulterrorhandler 35. raise errorclass, errorvalue Exception Type: UnicodeDecodeError at / Exception Value: 'utf8' codec can't decode bytes in position 0-1: invalid data So, I get this exception (on some page loads) only with "runfcgi". I never see this happen using "runserver". I could reproduce it on 2 different servers : - Fedora Core 4 (cpanel) - mysql 4.1.22 - CentOS 4.6 - mysql 4.1.20 However, I could NOT reproduce it on the following server : - CentOS 5.1 - mysql 5.0.22 With some more testing, I reproduced it using - CentOS 4.6 with local mysql 4.1.20, using remote DB on CentOS 5.1 - mysql 5.0.22 But NOT with : - CentOS 5.1 with local mysql 5.0.22, using remote DB on CentOS 4.6 - mysql 4.1.20 Note that I could not test using mod_python (except on the server that did not have the problem with fastcgi), because of segmentation fault problems. So I can't say if the same unicode error would happen or not. I hope I gave enough information... I don't know if I should post this as a bug report. Maybe this is all caused by some stupid error I made ;) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---