Commits

Kai Diefenbach committed 9fe7807

Bugfix: prevent setting of unsupported locale; #issue 165.

Comments (0)

Files changed (2)

lfs/core/tests.py

         self.assertEqual(shop.meta_keywords, u"")
         self.assertEqual(shop.meta_description, u"")
 
+    def test_unsupported_locale(self):
+        """
+        """
+        shop = lfs.core.utils.get_default_shop()
+        shop.default_locale = "unsupported"
+        shop.save()
+
+        self.client.get("/")
+
     def test_from_email(self):
         """
         """

lfs/core/views.py

 from lfs.caching.utils import lfs_get_object_or_404
 from lfs.core.models import Shop
 
+# Load logger
+import logging
+logger = logging.getLogger("default")
+
 
 def shop_view(request, template_name="lfs/shop/shop.html"):
     """Displays the shop.
 
 def one_time_setup():
     shop = lfs_get_object_or_404(Shop, pk=1)
-    locale.setlocale(locale.LC_ALL, str(shop.default_locale))
+    try:
+        locale.setlocale(locale.LC_ALL, str(shop.default_locale))
+    except locale.Error, e:
+        logger.error("Unsupported locale in LMI/Preferences/Default Values/Default Shop Locale: '%s'." % shop.default_locale)