changeset 5422:ddfd18e00523

openidrp_sreg: handle UnknownTimeZoneError gracefully
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 11 Jan 2010 08:58:33 +0100
parents be610b894f10
children 7d0598a55c09
files MoinMoin/auth/openidrp_ext/openidrp_sreg.py
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/openidrp_ext/openidrp_sreg.py	Sun Jan 10 23:42:10 2010 +0100
+++ b/MoinMoin/auth/openidrp_ext/openidrp_sreg.py	Mon Jan 11 08:58:33 2010 +0100
@@ -80,11 +80,16 @@
                     sreg['language'] = sreg['language'][0:2]
         # Timezone must be converted to offset in seconds
         if sreg_resp.get('timezone'):
-            user_tz = timezone(sreg_resp.get('timezone').encode('ascii'))
-            if user_tz:
-                user_utcoffset = user_tz.utcoffset(datetime.utcnow())
-                sreg['timezone'] = user_utcoffset.days * 24 * 60 * 60 + user_utcoffset.seconds
+            try:
+                user_tz = timezone(sreg_resp.get('timezone').encode('ascii'))
+            except pytz.UnknownTimeZoneError:
+                pass # don't use
             else:
-                sreg['timezone'] = 0
+                if user_tz:
+                    user_utcoffset = user_tz.utcoffset(datetime.utcnow())
+                    sreg['timezone'] = user_utcoffset.days * 24 * 60 * 60 + user_utcoffset.seconds
+                else:
+                    # XXX when does user_tz get falsy? if it does, shouldn't we just 'pass'?
+                    sreg['timezone'] = 0
     return sreg