Author: phd
Date: Fri May 25 10:30:57 2012
New Revision: 4530
Log:
Merged revision 4529 from branch 1.2: fixed a bug in unpickling.
Modified:
SQLObject/branches/1.3/docs/News.txt
SQLObject/branches/1.3/sqlobject/main.py
Modified: SQLObject/branches/1.3/docs/News.txt
==============================================================================
--- SQLObject/branches/1.3/docs/News.txt Fri May 25 10:28:24 2012 (r4529)
+++ SQLObject/branches/1.3/docs/News.txt Fri May 25 10:30:57 2012 (r4530)
@@ -10,7 +10,7 @@
SQLObject 1.3.1
===============
-* A bugfix was ported from `SQLObject 1.2.3`_.
+* Two bugfixes were ported from `SQLObject 1.2.3`_.
SQLObject 1.3.0
===============
@@ -31,7 +31,9 @@
===============
* Fixed a minor bug in PostgreSQL introspection: VIEWs don't have
- PRIMARY KEYs - use sqlmeta.idName as the key if there is no one.
+ PRIMARY KEYs - use sqlmeta.idName as the key.
+
+* Fixed a bug in cache handling while unpickling.
SQLObject 1.2.2
===============
Modified: SQLObject/branches/1.3/sqlobject/main.py
==============================================================================
--- SQLObject/branches/1.3/sqlobject/main.py Fri May 25 10:28:24 2012 (r4529)
+++ SQLObject/branches/1.3/sqlobject/main.py Fri May 25 10:30:57 2012 (r4530)
@@ -1670,6 +1670,8 @@
return NotImplemented
+ # (De)serialization (pickle, etc.)
+
def __getstate__(self):
if self.sqlmeta._perConnection:
from pickle import PicklingError
@@ -1680,10 +1682,16 @@
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)
- self.__class__._connection.cache.put(self.id, self.__class__, self)
+ cache.created(id, cls, self)
def setterName(name):
|