mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #968 from russkel/encodingfix
Fix setting default locale and exception encoding
This commit is contained in:
commit
2aa0c6e24b
4 changed files with 14 additions and 3 deletions
|
|
@ -390,7 +390,7 @@ def main():
|
||||||
# so convert the message to unicode with the correct encoding
|
# so convert the message to unicode with the correct encoding
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
if not six.PY3:
|
if not six.PY3:
|
||||||
msg = msg.decode(locale.getpreferredencoding(False))
|
msg = msg.decode(locale.getpreferredencoding())
|
||||||
|
|
||||||
logger.critical(msg)
|
logger.critical(msg)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ DEFAULT_CONFIG = {
|
||||||
'MD_EXTENSIONS': ['codehilite(css_class=highlight)', 'extra'],
|
'MD_EXTENSIONS': ['codehilite(css_class=highlight)', 'extra'],
|
||||||
'JINJA_EXTENSIONS': [],
|
'JINJA_EXTENSIONS': [],
|
||||||
'JINJA_FILTERS': {},
|
'JINJA_FILTERS': {},
|
||||||
'LOCALE': [], # defaults to user locale
|
'LOCALE': [''], # defaults to user locale
|
||||||
'DEFAULT_PAGINATION': False,
|
'DEFAULT_PAGINATION': False,
|
||||||
'DEFAULT_ORPHANS': 0,
|
'DEFAULT_ORPHANS': 0,
|
||||||
'DEFAULT_METADATA': (),
|
'DEFAULT_METADATA': (),
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ GITHUB_URL = 'http://github.com/ametaireau/'
|
||||||
DISQUS_SITENAME = "blog-notmyidea"
|
DISQUS_SITENAME = "blog-notmyidea"
|
||||||
PDF_GENERATOR = False
|
PDF_GENERATOR = False
|
||||||
REVERSE_CATEGORY_ORDER = True
|
REVERSE_CATEGORY_ORDER = True
|
||||||
LOCALE = ""
|
|
||||||
DEFAULT_PAGINATION = 2
|
DEFAULT_PAGINATION = 2
|
||||||
|
|
||||||
FEED_RSS = 'feeds/all.rss.xml'
|
FEED_RSS = 'feeds/all.rss.xml'
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import unicode_literals, print_function
|
from __future__ import unicode_literals, print_function
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
|
import locale
|
||||||
from os.path import dirname, abspath, join
|
from os.path import dirname, abspath, join
|
||||||
|
|
||||||
from pelican.settings import (read_settings, configure_settings,
|
from pelican.settings import (read_settings, configure_settings,
|
||||||
|
|
@ -92,3 +93,14 @@ class TestSettingsConfiguration(unittest.TestCase):
|
||||||
settings['FEED_DOMAIN'] = 'http://feeds.example.com'
|
settings['FEED_DOMAIN'] = 'http://feeds.example.com'
|
||||||
configure_settings(settings)
|
configure_settings(settings)
|
||||||
self.assertEqual(settings['FEED_DOMAIN'], 'http://feeds.example.com')
|
self.assertEqual(settings['FEED_DOMAIN'], 'http://feeds.example.com')
|
||||||
|
|
||||||
|
def test_default_encoding(self):
|
||||||
|
# test that the default locale is set if
|
||||||
|
# locale is not specified in the settings
|
||||||
|
|
||||||
|
#reset locale to python default
|
||||||
|
locale.setlocale(locale.LC_ALL, str('C'))
|
||||||
|
self.assertEqual(self.settings['LOCALE'], DEFAULT_CONFIG['LOCALE'])
|
||||||
|
|
||||||
|
configure_settings(self.settings)
|
||||||
|
self.assertEqual(locale.getlocale(), locale.getdefaultlocale())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue