Fantomas42 / django-blog-zinnia

Simple yet powerful and really extendable application for managing a blog within your Django Web site.
http://django-blog-zinnia.com/
BSD 3-Clause "New" or "Revised" License
2.11k stars 730 forks source link

unsupported locale setting #5

Closed MichaelHipp closed 14 years ago

MichaelHipp commented 14 years ago

Just added zinnia to my django-cms. When trying the /weblog/ url it fails with the below debug information. This is on Windows 7.

TemplateSyntaxError at /weblog/

Caught Error while rendering: unsupported locale setting

Request Method: GET Request URL: http://127.0.0.1:8000/weblog/ Django Version: 1.2.1 Exception Type: TemplateSyntaxError Exception Value:

Caught Error while rendering: unsupported locale setting

Exception Location: C:\dropbox\Dev\virtenvs\redmule\lib\locale.py in setlocale, line 513 Python Executable: C:\dropbox\Dev\virtenvs\redmule\Scripts\python.exe Python Version: 2.6.4 Python Path: ['C:\dropbox\Dev\stable', 'C:\dropbox\Dev\stable\redmule', 'C:\dropbox\Dev\virtenvs\redmule\lib\site-packages\distribute-0.6.10-py2.6.egg', 'C:\dropbox\Dev\virtenvs\redmule\lib\site-packages\pip-0.6.3-py2.6.egg', 'c:\dropbox\dev\virtenvs\redmule\src\django-blog-zinnia', 'C:\Windows\system32\python26.zip', 'C:\dropbox\Dev\virtenvs\redmule\DLLs', 'C:\dropbox\Dev\virtenvs\redmule\lib', 'C:\dropbox\Dev\virtenvs\redmule\lib\plat-win', 'C:\dropbox\Dev\virtenvs\redmule\lib\lib-tk', 'C:\dropbox\Dev\virtenvs\redmule\Scripts', 'C:\Python26\Lib', 'C:\Python26\DLLs', 'C:\Python26\Lib\lib-tk', 'C:\dropbox\Dev\virtenvs\redmule', 'C:\dropbox\Dev\virtenvs\redmule\lib\site-packages', 'C:\Python26\lib\site-packages\pip-0.6.1-py2.6.egg', 'C:\Python26', 'C:\Python26\lib\site-packages', 'C:\Python26\lib\site-packages\PIL', 'C:\Python26\lib\site-packages', 'c:\dev', 'c:\dev\stable', 'c:\oss', 'c:\oss\django-cms-2.0', 'c:\oss\geraldo', 'C:\Python26\lib\site-packages\win32', 'C:\Python26\lib\site-packages\win32\lib', 'C:\Python26\lib\site-packages\Pythonwin', 'C:\Python26\lib\site-packages\wx-2.8-msw-ansi'] Server time: Sat, 3 Jul 2010 22:14:34 -0500 Template error

In template c:\dropbox\dev\virtenvs\redmule\src\django-blog-zinnia\zinnia\templates\zinnia\base.html, error at line 24 Caught Error while rendering: unsupported locale setting 14 15

16 17
18
19

{% trans "Categories" %}

20 {% get_categories %} 21
22
23

{% trans "Calendar" %}

24 {% get_calendar_entries %} 25
26
27

{% trans "Tags" %}

28 {% tag_cloud_for_model zinnia.entry as tag_cloud with steps=6 %} 29
Fantomas42 commented 14 years ago

Hi Michael,

thank you for the bug report. The traceback is not very clear, but it seems to be related to the Calendar widget.

Can you provide me the values of yours locales installed in your system, and the value of the LANGUAGES setting in your project.

I need these informations for reproducing the bug.

Regards,

Julien

MichaelHipp commented 14 years ago

Thank you.

Here's what I have in settings.py as related to languages and such: LANGUAGE_CODE = "en"

LANGUAGES = (

('fr', gettext('French')),

#('de', gettext('German')),
('en', gettext('English')),
#('pt-br', gettext("Brazil")),

)

CMS_LANGUAGE_CONF = {

'de':['fr', 'en'],

'en':['fr', 'de'],

}

TEMPLATE_CONTEXT_PROCESSORS = (

"django.core.context_processors.i18n",

MIDDLEWARE_CLASSES = (

'cms.middleware.multilingual.MultilingualURLMiddleware',

Figuring out exactly what 'locale' means in Windows doesn't seem straightforward, but here's what I have set in the Control Panel 'Regions and Languages' applet:

Format: English, United States Short date: M/d/y Long date: dddd, MMMM dd, yyyy Short time: h:mm tt Long time: h:mm:ss tt First day of week: Sunday

Location: United States System locale: English (United States)

Fantomas42 commented 14 years ago

What do you have if you type in your python interpreter ?

import locale locale.getdefaultlocale()

MichaelHipp commented 14 years ago

('en_US', 'cp1252')

Fantomas42 commented 14 years ago

Hi, if you use this file : http://github.com/redsolution/django-blog-zinnia/commit/0c83a1129cbb9608a66e08fcd9f2dc2b9c3dd89f

Does it work ?

MichaelHipp commented 14 years ago

It appears I'm still getting the same error. Here is the traceback:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/weblog/
Django Version: 1.2.1
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.sites',
 'cms',
 'publisher',
 'cms.plugins.text',
 'cms.plugins.picture',
 'cms.plugins.file',
 'cms.plugins.flash',
 'cms.plugins.link',
 'cms.plugins.snippet',
 'cms.plugins.googlemap',
 'cms.plugins.teaser',
 'cms.plugins.video',
 'cms.plugins.twitter',
 'cms.plugins.inherit',
 'mptt',
 'reversion',
 'redmule.categories',
 'south',
 'redmule.sampleapp',
 'redmule.timeapp',
 'redmule.wisdom',
 'redmule.advocacy',
 'django.contrib.comments',
 'tagging',
 'zinnia',
 'zinnia.plugins']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware',
 'cms.middleware.media.PlaceholderMediaMiddleware')

Template error:
In template c:\dev\virtenvs\redmule\lib\site-packages\django_blog_zinnia-0.6-py2.6.egg\zinnia\templates\zinnia\base.html, error at line 24
   Caught Error while rendering: unsupported locale setting
   14 :       <input type="submit" class="submitbutton" value="OK" />

   15 :     </p>

   16 :   </form>

   17 : </div>

   18 : <div class="categories">

   19 :   <h3>{% trans "Categories" %}</h3>

   20 :   {% get_categories %}

   21 : </div>

   22 : <div class="calendar">

   23 :   <h3>{% trans "Calendar" %}</h3>

   24 :    {% get_calendar_entries %} 

   25 : </div>

   26 : <div class="tags">

   27 :   <h3>{% trans "Tags" %}</h3>

   28 :   {% tag_cloud_for_model zinnia.entry as tag_cloud with steps=6 %}

   29 :   <ul>

   30 :     {% for tag in tag_cloud %}

   31 :     <li>

   32 :       <a href="{% url zinnia_tag_detail tag.name %}" title="{{ tag.count }} {% trans "entries" %}" class="tag_{{ tag.font_size }}">

   33 :     {{ tag }}

   34 :       </a>

Traceback:
File "C:\dev\virtenvs\redmule\lib\site-packages\django\core\handlers\base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "C:\dev\virtenvs\redmule\lib\site-packages\django_blog_zinnia-0.6-py2.6.egg\zinnia\views\decorators.py" in wrap
  13.         return view(*args, **kwargs)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\views\generic\list_detail.py" in object_list
  101.     return HttpResponse(t.render(c), mimetype=mimetype)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in render
  173.             return self._render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in _render
  167.         return self.nodelist.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in render
  796.                 bits.append(self.render_node(node, context))
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\debug.py" in render_node
  72.             result = node.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\loader_tags.py" in render
  125.         return compiled_parent._render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in _render
  167.         return self.nodelist.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in render
  796.                 bits.append(self.render_node(node, context))
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\debug.py" in render_node
  72.             result = node.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\loader_tags.py" in render
  125.         return compiled_parent._render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in _render
  167.         return self.nodelist.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in render
  796.                 bits.append(self.render_node(node, context))
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\debug.py" in render_node
  72.             result = node.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\loader_tags.py" in render
  125.         return compiled_parent._render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in _render
  167.         return self.nodelist.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in render
  796.                 bits.append(self.render_node(node, context))
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\debug.py" in render_node
  72.             result = node.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in render
  796.                 bits.append(self.render_node(node, context))
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\debug.py" in render_node
  72.             result = node.render(context)
File "C:\dev\virtenvs\redmule\lib\site-packages\django\template\__init__.py" in render
  954.                     dict = func(*args)
File "C:\dev\virtenvs\redmule\lib\site-packages\django_blog_zinnia-0.6-py2.6.egg\zinnia\templatetags\zinnia_tags.py" in get_calendar_entries
  132.             'calendar': calendar.formatmonth(year, month)}
File "C:\dev\virtenvs\redmule\lib\site-packages\django_blog_zinnia-0.6-py2.6.egg\zinnia\templatetags\zcalendar.py" in formatmonth
  40.         return super(ZinniaCalendar, self).formatmonth(theyear, themonth, withyear)
File "C:\Python26\Lib\calendar.py" in formatmonth
  427.         a(self.formatmonthname(theyear, themonth, withyear=withyear))
File "C:\Python26\Lib\calendar.py" in formatmonthname
  552.         with TimeEncoding(self.locale) as encoding:
File "C:\Python26\Lib\calendar.py" in __enter__
  489.         self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
File "C:\dev\virtenvs\redmule\lib\locale.py" in setlocale
  513.     return _setlocale(category, locale)

Exception Type: TemplateSyntaxError at /weblog/
Exception Value: Caught Error while rendering: unsupported locale setting
qgriffith-zz commented 14 years ago

Hello I am having the same issue on OSX and the file you link to earlier in this thread also does not work for me. Here is the resulsts of my local

Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole)

import locale locale.getdefaultlocale() ('en_US', 'UTF8')

Fantomas42 commented 14 years ago

Ok, I have an idea to fix it, but I need to get an OSX on hand to reproduce the bug.

qgriffith-zz commented 14 years ago

My development box is OSX once done I tend to move the project to a Gentoo Linux server, do you know if the issue is also on Linux? I can help with the OSX piece, if there are files you want me to try or commands you need ran to see the output. We can do it via email or plan to meet up online one day.

Fantomas42 commented 14 years ago

Hi qgriffith,

I really appreciate your help, it will write some patches for testing. For the now it's only append on OS differents than Unix/Linux.

Fantomas42 commented 14 years ago

I have rewrited some parts of the calendar in 277b966c95324ee32520fcd1f5564628c43c6d99

Can someone test it ?

qgriffith-zz commented 14 years ago

It works on OSX!!!! Thank you for the super quick fix

Fantomas42 commented 14 years ago

Super !

MichaelHipp commented 14 years ago

I'm no longer getting the error and the blog appears correctly. Thank you!