'Validates a timezone.'

def Validate(self, value, key=None):

    if (value is None):
        return
    if (not isinstance(value, basestring)):
        raise TypeError(("timezone    must    be    a    string,    not    '%r'" % type(value)))
    if (pytz is None):
        return value
    try:
        pytz.timezone(value)
    except pytz.UnknownTimeZoneError:
        raise validation.ValidationError(("timezone    '%s'    is    unknown" % value))
    except IOError:
        return value
    except:
        (unused_e, v, t) = sys.exc_info()
        logging.warning(((('pytz    raised    an    unexpected    error:    %s.\n' % v) + 'Traceback:\n') + '\n'.join(traceback.format_tb(t))))
        raise
    return value
