[Zope-dev] Re: Changing DateTime to use pytz

Laurence Rowe l at lrowe.co.uk
Fri Oct 5 09:49:00 EDT 2007


Lennart Regebro wrote:
> On 10/5/07, Laurence Rowe <l at lrowe.co.uk> wrote:
>> I've tested my patch (datetime.datetime support) against Amos's branch
>> and it applies cleanly and all tests pass.
> 
> Cool! Are there tests to make sure old pickles still work, or do we
> know that this is the case for sure?
> 

My patch updates the existing test (substituting _millis for _micros):

     def testUpgradeOldInstances(self):
         # Compare dates that don't have the _micros attribute yet
         dt = DateTime('1997/1/1')
         dt1 = DateTime('1997/2/2')
         del dt._micros
         del dt1._micros
         self.testCompareOperations(dt, dt1)

If anyone thinks it is important I could an explicit upgrade path for 
instances with a _millis attribute too (most current instances I would 
assume). _upgrade_old should work fine for them too as they have a time 
float _t attribute.

     def _upgrade_old(self):
         """Upgrades a previously pickled DateTime object."""
         micros = long(math.floor(self._t * 1000000.0))
         self._micros = micros
         return micros

Laurence



More information about the Zope-Dev mailing list