Log message for revision 80926: Changed pytz support not to check for the presence of pytz. We know pytz will be present. Changes as per Andreas's request.
Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/DateTime/DateTime.py U Zope/trunk/lib/python/DateTime/pytz.txt U Zope/trunk/lib/python/DateTime/tests/testDateTime.py -=- Modified: Zope/trunk/doc/CHANGES.txt =================================================================== --- Zope/trunk/doc/CHANGES.txt 2007-10-18 17:15:17 UTC (rev 80925) +++ Zope/trunk/doc/CHANGES.txt 2007-10-18 17:50:15 UTC (rev 80926) @@ -173,9 +173,9 @@ view to work. (patch by Sidnei da Silva from Enfold, integration by Martijn Faassen (Startifact) for Infrae) - - DateTime now uses pytz for time zone data if available. This - means support for more time zones and up to date daylight - saving time information. + - DateTime now uses pytz for time zone data. This means support + for more time zones and up to date daylight saving time + information. Bugs Fixed Modified: Zope/trunk/lib/python/DateTime/DateTime.py =================================================================== --- Zope/trunk/lib/python/DateTime/DateTime.py 2007-10-18 17:15:17 UTC (rev 80925) +++ Zope/trunk/lib/python/DateTime/DateTime.py 2007-10-18 17:50:15 UTC (rev 80926) @@ -22,11 +22,7 @@ from interfaces import IDateTime from interfaces import DateTimeError, SyntaxError, DateError, TimeError from zope.interface import implements -try: - from pytz_support import PytzCache -except ImportError: - # pytz not available, use legacy timezone support - PytzCache = None +from pytz_support import PytzCache default_datefmt = None @@ -992,12 +988,8 @@ # For backward compatibility only: _isDST = localtime(time())[8] _localzone = _isDST and _localzone1 or _localzone0 + _tzinfo = PytzCache(_cache()) - if PytzCache is not None: - _tzinfo = PytzCache(_cache()) - else: - _tzinfo = _cache() - def localZone(self, ltm=None): '''Returns the time zone on the given date. The time zone can change according to daylight savings.''' @@ -2049,6 +2041,5 @@ # Module methods def Timezones(): """Return the list of recognized timezone names""" - if PytzCache is not None: - return list(PytzCache(_cache())._zlst) - return _cache._zlst + return list(PytzCache(_cache())._zlst) + Modified: Zope/trunk/lib/python/DateTime/pytz.txt =================================================================== --- Zope/trunk/lib/python/DateTime/pytz.txt 2007-10-18 17:15:17 UTC (rev 80925) +++ Zope/trunk/lib/python/DateTime/pytz.txt 2007-10-18 17:50:15 UTC (rev 80926) @@ -1,18 +1,13 @@ Pytz Support ============ -If the pytz package is importable, it will be used for time zone -information, otherwise, DateTime's own time zone database is used. The + +Allows the pytz package to be used for time zone information. The advantage of using pytz is that it has a more complete and up to date time zone and daylight savings time database. -This test assumes that pytz is available. - - >>> import pytz - Usage ----- -If pytz is available, then DateTime will use it. You don't have to do -anything special to make it work. +You don't have to do anything special to make it work. >>> from DateTime import DateTime, Timezones >>> d = DateTime('March 11, 2007 US/Eastern') @@ -53,9 +48,9 @@ -18000 Time Zones ----------- -When pytz is available, DateTime can use its large database of time -zones. Here are some examples: +--------- +DateTime can use pytz's large database of time zones. Here are some +examples: >>> d = DateTime('Pacific/Kwajalein') >>> d = DateTime('America/Shiprock') @@ -75,13 +70,12 @@ >>> d = DateTime('iceland') These time zones use DateTimes database. So it's preferable to use the -official time zone name when you have pytz installed. +official time zone name. One trickiness is that DateTime supports some zone name -abbreviations. Some of these map to pytz names, so when pytz is -present these abbreviations will give you time zone date from -pytz. Notable among abbreviations that work this way are 'est', 'cst', -'mst', and 'pst'. +abbreviations. Some of these map to pytz names, so these abbreviations +will give you time zone date from pytz. Notable among abbreviations +that work this way are 'est', 'cst', 'mst', and 'pst'. Let's verify that 'est' picks up the 2007 daylight savings time changes. @@ -115,7 +109,7 @@ Cache ~~~~~ -When pytz is present, the DateTime class uses a different time zone cache. +The DateTime class uses a new time zone cache. >>> DateTime._tzinfo #doctest: +ELLIPSIS <DateTime.pytz_support.PytzCache instance at ...> Modified: Zope/trunk/lib/python/DateTime/tests/testDateTime.py =================================================================== --- Zope/trunk/lib/python/DateTime/tests/testDateTime.py 2007-10-18 17:15:17 UTC (rev 80925) +++ Zope/trunk/lib/python/DateTime/tests/testDateTime.py 2007-10-18 17:50:15 UTC (rev 80926) @@ -509,20 +509,12 @@ def test_suite(): from zope.testing import doctest - try: - # if pytz is available include a test for it - import pytz - return unittest.TestSuite([ - unittest.makeSuite(DateTimeTests), - doctest.DocFileSuite('DateTime.txt', package='DateTime'), - doctest.DocFileSuite('pytz.txt', package='DateTime'), - ]) + return unittest.TestSuite([ + unittest.makeSuite(DateTimeTests), + doctest.DocFileSuite('DateTime.txt', package='DateTime'), + doctest.DocFileSuite('pytz.txt', package='DateTime'), + ]) - except ImportError: - return unittest.TestSuite([ - unittest.makeSuite(DateTimeTests), - doctest.DocFileSuite('DateTime.txt', package='DateTime') - ]) if __name__=="__main__": unittest.main(defaultTest='test_suite') _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins