[Zodb-checkins] SVN: ZODB/branches/tseaver-python_picklecache-2/src/persistent/ Use TimeStamp object to compute _p_mtime.
Tres Seaver
tseaver at palladion.com
Wed Feb 16 21:32:20 EST 2011
Log message for revision 120404:
Use TimeStamp object to compute _p_mtime.
Also, normalize imports.
Changed:
U ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py
U ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py
-=-
Modified: ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py
===================================================================
--- ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py 2011-02-17 02:32:17 UTC (rev 120403)
+++ ZODB/branches/tseaver-python_picklecache-2/src/persistent/pyPersistence.py 2011-02-17 02:32:19 UTC (rev 120404)
@@ -12,10 +12,8 @@
#
##############################################################################
from copy_reg import __newobj__
-import datetime
import struct
import sys
-import time
from zope.interface import implements
@@ -25,6 +23,7 @@
from persistent.interfaces import UPTODATE
from persistent.interfaces import CHANGED
from persistent.interfaces import STICKY
+from persistent.timestamp import TimeStamp
if sys.version_info < (2, 6,):
OID_TYPE = SERIAL_TYPE = str
@@ -167,8 +166,8 @@
# _p_mtime
def _get_mtime(self):
if self.__serial is not None:
- when = datetime.datetime(*parseTimestamp(self.__serial))
- return time.mktime(when.timetuple())
+ ts = TimeStamp(self.__serial)
+ return ts.timeTime()
_p_mtime = property(_get_mtime)
Modified: ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py
===================================================================
--- ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py 2011-02-17 02:32:17 UTC (rev 120403)
+++ ZODB/branches/tseaver-python_picklecache-2/src/persistent/tests/test_pyPersistence.py 2011-02-17 02:32:19 UTC (rev 120404)
@@ -431,14 +431,12 @@
self.assertEqual(inst._p_mtime, None)
def test__p_mtime_w_serial(self):
- import datetime
- import time
- from persistent.pyPersistence import makeTimestamp
+ from persistent.timestamp import TimeStamp
WHEN_TUPLE = (2011, 2, 15, 13, 33, 27.5)
- WHEN = datetime.datetime(*WHEN_TUPLE)
+ ts = TimeStamp(*WHEN_TUPLE)
inst, jar, OID = self._makeOneWithJar()
- inst._p_serial = makeTimestamp(*WHEN_TUPLE)
- self.assertEqual(inst._p_mtime, time.mktime(WHEN.timetuple()))
+ inst._p_serial = ts.raw()
+ self.assertEqual(inst._p_mtime, ts.timeTime())
def test__p_state_new(self):
inst = self._makeOne()
More information about the Zodb-checkins
mailing list