Commits

Yu-Jie Lin  committed fd831a4

Fix 500 error caused by invalid timezone

  • Participants
  • Parent commits 82a99aa

Comments (0)

Files changed (1)

File gaewiki/settings.py

 # encoding=utf-8
 
+import logging
+
+from pytz.gae import pytz
+
 import model
 import util
 
     settings = memcache.get('gaewiki:settings')
     if settings is None:
         settings = util.parse_page(get_host_page().body)
+        try:
+            pytz.timezone(settings['timezone'])
+        except pytz.UnknownTimeZoneError as e:
+            logging.warning('Unknown timezone: %s, reset to UTC' % settings['timezone'])
+            settings['timezone'] = 'UTC'
         memcache.set('gaewiki:settings', settings)
     return settings