[SQL-CVS] r4533 - in SQLObject/branches/1.3/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2012-05-25 18:47:23
|
Author: phd Date: Fri May 25 12:47:15 2012 New Revision: 4533 Log: Merged revision 4532 from branch 1.2: use cache.tryGet() instead of cache.get(). Modified: SQLObject/branches/1.3/sqlobject/main.py SQLObject/branches/1.3/sqlobject/tests/test_pickle.py Modified: SQLObject/branches/1.3/sqlobject/main.py ============================================================================== --- SQLObject/branches/1.3/sqlobject/main.py Fri May 25 12:45:46 2012 (r4532) +++ SQLObject/branches/1.3/sqlobject/main.py Fri May 25 12:47:15 2012 (r4533) @@ -1682,15 +1682,14 @@ return d def __setstate__(self, d): - id = d['id'] - cls = self.__class__ - cache = self._connection.cache - if cache.get(id, cls) is not None: - raise ValueError( - "Cannot unpickle %s row with id=%s - the id already exists in the cache" % (cls.__name__, id)) self.__init__(_SO_fetch_no_create=1) self._SO_writeLock = threading.Lock() self.__dict__.update(d) + cls = self.__class__ + cache = self._connection.cache + if cache.tryGet(self.id, cls) is not None: + raise ValueError( + "Cannot unpickle %s row with id=%s - a different instance with the id already exists in the cache" % (cls.__name__, self.id)) cache.created(id, cls, self) Modified: SQLObject/branches/1.3/sqlobject/tests/test_pickle.py ============================================================================== --- SQLObject/branches/1.3/sqlobject/tests/test_pickle.py Fri May 25 12:45:46 2012 (r4532) +++ SQLObject/branches/1.3/sqlobject/tests/test_pickle.py Fri May 25 12:47:15 2012 (r4533) @@ -15,15 +15,16 @@ def test_pickleCol(): setupClass(TestPickle) + connection = TestPickle._connection test = TestPickle(question=test_question, answer=test_answer) pickle_data = pickle.dumps(test, pickle.HIGHEST_PROTOCOL) + connection.cache.clear() test = pickle.loads(pickle_data) assert test.question == test_question assert test.answer == test_answer - connection = TestPickle._connection if (connection.dbName == 'sqlite') and connection._memory: return # The following test requires a different connection |