Author: phd
Date: 2006-10-03 11:31:09 -0600 (Tue, 03 Oct 2006)
New Revision: 1975
Modified:
home/phd/SQLObject/paramstyles/sqlobject/main.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_cache.py
Log:
Merged patches from the revisions 1967:1974 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2006-10-03 17:29:35 UTC (rev 1974)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2006-10-03 17:31:09 UTC (rev 1975)
@@ -35,6 +35,7 @@
"""
import threading
+import weakref
import sqlbuilder
import dbconnection
import col
@@ -246,7 +247,7 @@
declarative.setup_attributes(cls, new_attrs)
def __init__(self, instance):
- self.instance = instance
+ self.instance = weakref.proxy(instance)
def send(cls, signal, *args, **kw):
events.send(signal, cls.soClass, *args, **kw)
@@ -1590,7 +1591,7 @@
class SQLObjectState(object):
def __init__(self, soObject):
- self.soObject = soObject
+ self.soObject = weakref.proxy(soObject)
self.protocol = 'sql'
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_cache.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_cache.py 2006-10-03 17:29:35 UTC (rev 1974)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_cache.py 2006-10-03 17:31:09 UTC (rev 1975)
@@ -35,16 +35,14 @@
assert not s.sqlmeta.expired
CacheTest.sqlmeta.expireAll()
assert s.sqlmeta.expired
- del s
CacheTest.sqlmeta.expireAll()
- s = CacheTest.get(s_id)
+ s1 = CacheTest.get(s_id)
# We should have a new object:
- assert id(s) != obj_id
- obj_id2 = id(s)
- del s
+ assert id(s1) != obj_id
+ obj_id2 = id(s1)
CacheTest._connection.expireAll()
- s = CacheTest.get(s_id)
- assert id(s) != obj_id and id(s) != obj_id2
+ s2 = CacheTest.get(s_id)
+ assert id(s2) != obj_id and id(s2) != obj_id2
def test_cache_cull():
setupClass(CacheTest)
|