[Python-Dev] Stdlib and timezones, again (original) (raw)
Christian Heimes christian at python.org
Mon Oct 1 01:24:09 CEST 2012
- Previous message: [Python-Dev] Stdlib and timezones, again
- Next message: [Python-Dev] Stdlib and timezones, again
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 30.09.2012 20:18, schrieb Gregory P. Smith:
We never hear anyone complain because the corrections are not for English or other "western" languages that the majority of us speak. ;)
Regardless, I think including a version of the database on windows releases makes sense. Update it on a best effort basis before each .x minor release. The documentation can make it clear that it is a changing database how to use an updated version with your application. One additional thing I'd like to see: Don't let the successful importing of a 'pytzdata' module be the only way to get an updated tz database. Create an API for someone to supply one themselves at runtime that is cleaner than shoving something into sys.modules['pytzdata']. And define in which order they'll be used: priority: 1) api call supplying tz data to the process. 2) pytzdata module if it exists 3) tz data from the underlying operating system 4) error.
I like your basic approach but I'm suggesting a slightly different approach. Before I explain my proposal I like to get a naming convention straight.
integrated tz database
A copy of the Olson database that is shipped with every version of Python (not just Windows). The integrated database is updated with every feature release of Python.
system tz database
That's an interface to the operating system's or platform's tz database. We probably have to provide multiple backends for different OSes, Java etc.
update tz database
A PyPI package that contains a current version of the Olson database. A new version of the update tz should be provided by the Python core developer team every time a new Olson database is available. The updatetz must never be distributed with the Python source code and shall not be installed by a distributor. Optionally we can include the code that creates an update tz package from a Olson database.
By default Python tries to load the updatetz first, then systemtz (if available) and finally the integratedtz. A user can query the status and version of the databases, set and get the currently used database with three functions. The used database can also be set with an environment variable:
datetime.gettzdatabase() -> "integrated" or "system" or "update" datetime.settzdatabase(name) datetime.listtzdatabases() -> {"integrated": "version", "system": "???" "update": "version", # only if an update tz db is installed } PYTHON_TZDB = "integrated" or "system" or "update"
With this setup users get the full benefit of system updates but can use the integrated or update database if they don't like the operating system's data.
Christian
- Previous message: [Python-Dev] Stdlib and timezones, again
- Next message: [Python-Dev] Stdlib and timezones, again
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]