durusmail: durus-users: Re: Pickle error - pytz
Pickle error - pytz
2005-01-01
Re: Pickle error - pytz
2005-01-01
2005-01-01
2005-01-01
2005-01-01
Re: Pickle error - pytz
Michael Watkins
2005-01-01
> On Jan 1, 2005, at 9:43 AM, Michael Watkins wrote:
>> PSPS: Different although related topic, have you folks had any
>> thoughts of
>> making Dulcina objects use tzinfo aware dates as a default? a now()
>> that
>> returned a datetime with tzinfo filled in - even if its merely
>> US/Eastern
>> - would make timezone conversion for other apps and zones relatively
>> trivial then.
>
> Would it be just as good if Dulcinea used utcnow() instead of now()?

Yes, that would be a useful step forward as it would remove the ambiguity
as to what "date" means.

Background, ramble, what I've done...

I'm refactoring/rewriting an older Quixote app with a Postgres datastore,
moving from qx 1.x / postgres to qx 2.x / Dulcinea / Durus. I am not yet
deep into updating my ui / ptl pages but noted that the use of naive dates
based on machine time would have been difficult to work around. I could
just convert them in the UI and override only those Dulcinea UI items that
offend.

But there is a got-ya here -- the problem with changing to utcnow() is
that others may find it problematic, primarily in the ui I would imagine,
although there may be side effects such as an imaginary
get_items_from_date(date) - which date, timezone, should be used? Myself
I'm using an app "default" timezone in such a function, regardless of what
the user's local preference might be, as that makes sense for this
application.

Perhaps Dulcinea might have to tread there too. My head hurts... Too bad
we don't all speak the same language and live in the same timezone.

The ui might be easier to deal with though - util.date_format /
util.datetime_format could be made to use the local_ui facility to allow
apps to override.

And/or another option might be to add a couple of utility functions, to be
overriden via a get_config and/or local.py customization by an app? I've
done something like this: get/set_default_timezone and
get/set_machine_timezone -

I've have pair of date_format/datetime_format utility functions that allow
for format customizations but also take a tzinfo unaware datetime object
and, making an assumption, convert them for output. i.e.

tmp_time = datetimeinstance.replace(tzinfo=get_default_timezone())

And the app gets its timezone defaults from this:

from dulcinea.site_util import get_config_value
from sous.date import *

try:
    from parlez.local import DEFAULT_TIMEZONE
except:
    DEFAULT_TIMEZONE = \
        timezones.get(get_config_value('default_timezone', 'US/Eastern'))

try:
    from parlez.local import MACHINE_TIMEZONE
except:
    MACHINE_TIMEZONE = \
        timezones.get(get_config_value('machine_timezone', 'US/Pacific'))

set_machine_timezone(MACHINE_TIMEZONE)
set_default_timezone(DEFAULT_TIMEZONE)

Cheers
Mike

reply