[Moin-user] Proper timezone support using pytz

Thomas Waldmann tw-public at gmx.de
Tue Nov 3 06:47:35 EST 2009

> > try:
> >     import pytz
> > except ImportError:
> >     pytz = None
> > 
> > if pytz:
> >     # pytz is there
> > else:
> >     # no pytz
> Heh. I actually pondered doing it that way, but concluded "if
> pytz_available:" was more readable / less cryptic.

Yeah, right. OTOH, we use this "module = None" thing also at other
places, so feel free to use it there, too.

And if you think of it as a question "pytz? -> there is None!" it maybe
isn't even that cryptic. :)

> How about deleting tz_offset from profiles only when they are saved with
> a user-provided tz_name ?


BTW, you need to modify multiconfig.py to provide a wiki-wide default
for tz_name (see the setting for the wiki-wide default for tz_offset).
While this is not very useful for international internet wikis, it is
quite useful for intranet or for local communities.

The default for the wiki-wide tz_name default should be maybe that "not
set" value.

> This all makes sense, but there is one remaining issue:
> If we make Moin only optionally use pytz, what should it do when
> encountering a pytz-enabled user profile when the pytz module is not
> available?
> (e.g., if pytz was previously installed, but is no longer installed.)
> I vote that this is a corner case that is not worth putting too much
> thought into, and that Moin should just revert to letting the affected
> users configure their tz_offset, and using its configured default
> tz_offset until they do.


More information about the Moin-user mailing list