My self.request.locale object is set but seems to be wrong
str(self.request.locale.id) => <LocaleIdentity (en, None, US, None)>
while I'd expect it to be something like Australia/Sydney.
Is this a default locale?
On Sun, 2005-08-28 at 23:30 -0400, Gary Poster wrote:
> On Aug 28, 2005, at 10:59 PM, Stephan Richter wrote:
> > On Sunday 28 August 2005 21:10, Alen Stanisic wrote:
> >> what's the best way to obtain timezone from request object. I tried
> >> tz = pytz.timezone(ITZInfo(self.request))
> >> but the adaptation failed.
> > Getting a single time zone from the request is not sensible.
> > Requests know
> > only about the locale. But the locale can be applicable in multiple
> > timezones. However, the locale usually knows about the timezones
> > that are
> > part of the locale. The object ``request.locale.dates.timezones`` is a
> > mapping from timezone names (in the ICU format) to
> > ``zope.i18n.interfaces.locales.ITimeZone`` objects.
> Other excitement: the timezone names in the ICU database do not all
> correspond to the timezones in the olson timezone database (upon
> which pytz is based).
> Generally, you want to let users choose their timezone. Guessing can
> work like this though (Py 2.4):
> ALL_TIMEZONES = frozenset(pytz.all_timezones)
> for t in self.request.locale.dates.timezones.keys():
> if t in ALL_TIMEZONES:
> return pytz.timezone(t)
> Maybe the ICU timezone object has alternate names to try in Olson; I
> > Unfortunately the version of the ICU data we are using does not
> > have very good
> > timezone support. At some point we need to switch to a newer
> > version, which
> > is much better with timezones as far as I remember.
> I looked around at this a month or two ago and didn't see much
> improvements, actually. Maybe I'm wrong.
> Zope3-users mailing list
Zope3-users mailing list