Commit c35f2528 authored by Jason Madden's avatar Jason Madden

Rollback some changes now that Python persistent handles registering objects...

Rollback some changes now that Python persistent handles registering objects during __setstate__ the same way as C persistent.
parent b25eb532
...@@ -2,6 +2,7 @@ language: python ...@@ -2,6 +2,7 @@ language: python
sudo: false sudo: false
python: python:
- pypy - pypy
- pypy3
- 2.6 - 2.6
- 2.7 - 2.7
- 3.2 - 3.2
......
...@@ -76,14 +76,7 @@ class Blob(persistent.Persistent): ...@@ -76,14 +76,7 @@ class Blob(persistent.Persistent):
_p_blob_committed = None # Filename of the committed data _p_blob_committed = None # Filename of the committed data
_p_blob_ref = None # weakreference to self; also in _blob_close_refs _p_blob_ref = None # weakreference to self; also in _blob_close_refs
# Use volatile attributes so as not to spuriously mark as changed. readers = writers = None
# The properties are aliases for BWC
readers = property(lambda self: getattr(self, '_v_readers', None),
lambda self, nv: setattr(self, '_v_readers', nv))
writers = property(lambda self: getattr(self, '_v_writers', None),
lambda self, nv: setattr(self, '_v_writers', nv))
_v_readers = None
_v_writers = None
def __init__(self, data=None): def __init__(self, data=None):
# Raise exception if Blobs are getting subclassed # Raise exception if Blobs are getting subclassed
...@@ -98,14 +91,8 @@ class Blob(persistent.Persistent): ...@@ -98,14 +91,8 @@ class Blob(persistent.Persistent):
def __setstate__(self, state=None): def __setstate__(self, state=None):
# we use lists here because it will allow us to add and remove # we use lists here because it will allow us to add and remove
# atomically # atomically
# Directly use the volatile attributes here, not the property, self.readers = []
# because setting the property causes us to get marked as changed, self.writers = []
# which registers us with the Connection and hence the transaction;
# at least under the Python implementation of persistent this causes
# duplicate transaction errors from the storage in testblob.
# Plus this way is more efficient anyway :)
self._v_readers = []
self._v_writers = []
def __getstate__(self): def __getstate__(self):
return None return None
...@@ -164,8 +151,8 @@ class Blob(persistent.Persistent): ...@@ -164,8 +151,8 @@ class Blob(persistent.Persistent):
if self.writers: if self.writers:
raise BlobError("Already opened for writing.") raise BlobError("Already opened for writing.")
if self._v_readers is None: if self.readers is None:
self._v_readers = [] self.readers = []
if mode == 'r': if mode == 'r':
result = None result = None
......
...@@ -177,7 +177,6 @@ def _functest_load(fqn): ...@@ -177,7 +177,6 @@ def _functest_load(fqn):
# Open the database and attempt to deserialize the tree # Open the database and attempt to deserialize the tree
# (run in separate process) # (run in separate process)
from ZODB import DB from ZODB import DB
import transaction
WORKING, FAILING = _working_failing_datetimes() WORKING, FAILING = _working_failing_datetimes()
db = DB(fqn) db = DB(fqn)
conn = db.open() conn = db.open()
...@@ -186,7 +185,6 @@ def _functest_load(fqn): ...@@ -186,7 +185,6 @@ def _functest_load(fqn):
tree = root['tree'] tree = root['tree']
assert tree[WORKING] == 'working' assert tree[WORKING] == 'working'
assert tree[FAILING] == 'failing' assert tree[FAILING] == 'failing'
transaction.abort()
finally: # Windoze finally: # Windoze
conn.close() conn.close()
db.close() db.close()
......
...@@ -52,7 +52,7 @@ class RegularObject(Persistent): ...@@ -52,7 +52,7 @@ class RegularObject(Persistent):
class PersistentObject(Persistent): class PersistentObject(Persistent):
pass pass
class CacheTests(object): class CacheTests:
def test_cache(self): def test_cache(self):
r"""Test basic cache methods. r"""Test basic cache methods.
......
[tox] [tox]
envlist = py26,py27,py32,py33,py34,pypy,simple envlist = py26,py27,py32,py33,py34,pypy,simple,pypy3
[testenv] [testenv]
commands = commands =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment