Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
7f38c7b1
Commit
7f38c7b1
authored
Apr 22, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python 2.1 compatibility.
parent
71c685b0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
22 deletions
+48
-22
src/ZEO/ClientStorage.py
src/ZEO/ClientStorage.py
+23
-5
src/ZEO/tests/ConnectionTests.py
src/ZEO/tests/ConnectionTests.py
+7
-2
src/ZODB/Connection.py
src/ZODB/Connection.py
+4
-1
src/ZODB/DB.py
src/ZODB/DB.py
+3
-3
src/ZODB/tests/testZODB.py
src/ZODB/tests/testZODB.py
+11
-11
No files found.
src/ZEO/ClientStorage.py
View file @
7f38c7b1
...
...
@@ -214,7 +214,7 @@ class ClientStorage:
# _is_read_only stores the constructor argument
self
.
_is_read_only
=
read_only
# _conn_is_read_only stores the status of the current connection
self
.
_conn_is_read_only
=
False
self
.
_conn_is_read_only
=
0
self
.
_storage
=
storage
self
.
_read_only_fallback
=
read_only_fallback
# _server_addr is used by sortKey()
...
...
@@ -367,7 +367,7 @@ class ClientStorage:
"""
log2
(
INFO
,
"Testing connection %r"
%
conn
)
# XXX Check the protocol version here?
self
.
_conn_is_read_only
=
False
self
.
_conn_is_read_only
=
0
stub
=
self
.
StorageServerStubClass
(
conn
)
try
:
stub
.
register
(
str
(
self
.
_storage
),
self
.
_is_read_only
)
...
...
@@ -377,7 +377,7 @@ class ClientStorage:
raise
log2
(
INFO
,
"Got ReadOnlyError; trying again with read_only=1"
)
stub
.
register
(
str
(
self
.
_storage
),
read_only
=
1
)
self
.
_conn_is_read_only
=
True
self
.
_conn_is_read_only
=
1
return
0
def
notifyConnected
(
self
,
conn
):
...
...
@@ -559,7 +559,7 @@ class ClientStorage:
def
isReadOnly
(
self
):
"""Storage API: return whether we are in read-only mode."""
if
self
.
_is_read_only
:
return
True
return
1
else
:
# If the client is configured for a read-write connection
# but has a read-only fallback connection, _conn_is_read_only
...
...
@@ -961,12 +961,18 @@ class ClientStorage:
end
=
endVerify
Invalidate
=
invalidateTrans
try
:
StopIteration
except
NameError
:
class
StopIteration
(
Exception
):
pass
class
InvalidationLogIterator
:
"""Helper class for reading invalidations in endVerify."""
# XXX will require extra work to backport to Python 2.1
def
__init__
(
self
,
fileobj
):
self
.
_unpickler
=
cPickle
.
Unpickler
(
fileobj
)
self
.
getitem_i
=
0
def
__iter__
(
self
):
return
self
...
...
@@ -976,3 +982,15 @@ class InvalidationLogIterator:
if
oid
is
None
:
raise
StopIteration
return
oid
,
version
# The __getitem__() method is needed to support iteration
# in Python 2.1.
def
__getitem__
(
self
,
i
):
assert
i
==
self
.
getitem_i
try
:
obj
=
self
.
next
()
except
StopIteration
:
raise
IndexError
,
i
self
.
getitem_i
+=
1
return
obj
src/ZEO/tests/ConnectionTests.py
View file @
7f38c7b1
...
...
@@ -438,6 +438,7 @@ class ConnectionTests(CommonSetupTearDown):
self
.
_storage
=
self
.
openClientStorage
()
self
.
_dostore
()
# Test case for multiple storages participating in a single
# transaction. This is not really a connection test, but it needs
# about the same infrastructure (several storage servers).
...
...
@@ -491,8 +492,12 @@ class ConnectionTests(CommonSetupTearDown):
get_transaction
().
commit
()
# make sure the invalidation is received in the other client
for
i
in
range
(
10
):
c1
.
_storage
.
sync
()
self
.
assert_
(
r1
.
_p_oid
in
c1
.
_invalidated
)
if
c1
.
_invalidated
.
has_key
(
r1
.
_p_oid
):
break
time
.
sleep
(
0.1
)
self
.
assert_
(
c1
.
_invalidated
.
has_key
(
r1
.
_p_oid
))
# force the invalidations to be applied...
c1
.
setLocalTransaction
()
...
...
src/ZODB/Connection.py
View file @
7f38c7b1
...
...
@@ -13,7 +13,10 @@
##############################################################################
"""Database connection support
$Id: Connection.py,v 1.88 2003/04/08 15:55:44 jeremy Exp $"""
$Id: Connection.py,v 1.89 2003/04/22 18:04:37 jeremy Exp $"""
from
__future__
import
nested_scopes
from
cPickleCache
import
PickleCache
from
POSException
import
ConflictError
,
ReadConflictError
,
TransactionError
from
ExtensionClass
import
Base
...
...
src/ZODB/DB.py
View file @
7f38c7b1
...
...
@@ -13,8 +13,8 @@
##############################################################################
"""Database objects
$Id: DB.py,v 1.4
8 2003/04/08 15:55:44
jeremy Exp $"""
__version__
=
'$Revision: 1.4
8
$'
[
11
:
-
2
]
$Id: DB.py,v 1.4
9 2003/04/22 18:04:37
jeremy Exp $"""
__version__
=
'$Revision: 1.4
9
$'
[
11
:
-
2
]
import
cPickle
,
cStringIO
,
sys
,
POSException
,
UndoLogCompatible
from
Connection
import
Connection
...
...
@@ -301,7 +301,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
version
=
connection
.
_version
# Update modified in version cache
# XXX must make this work with list or dict to backport to 2.6
for
oid
in
oids
:
for
oid
in
oids
.
keys
()
:
h
=
hash
(
oid
)
%
131
o
=
self
.
_miv_cache
.
get
(
h
,
None
)
if
o
is
not
None
and
o
[
0
]
==
oid
:
del
self
.
_miv_cache
[
h
]
...
...
src/ZODB/tests/testZODB.py
View file @
7f38c7b1
...
...
@@ -26,12 +26,12 @@ class P(Persistent):
class
Independent
(
Persistent
):
def
_p_independent
(
self
):
return
True
return
1
class
DecoyIndependent
(
Persistent
):
def
_p_independent
(
self
):
return
False
return
0
class
ZODBTests
(
unittest
.
TestCase
):
...
...
@@ -193,7 +193,7 @@ class ZODBTests(unittest.TestCase):
self
.
obj
=
P
()
self
.
readConflict
()
def
readConflict
(
self
,
shouldFail
=
True
):
def
readConflict
(
self
,
shouldFail
=
1
):
# Two transactions run concurrently. Each reads some object,
# then one commits and the other tries to read an object
# modified by the first. This read should fail with a conflict
...
...
@@ -237,10 +237,10 @@ class ZODBTests(unittest.TestCase):
root
[
"real_data"
]
=
real_data
=
PersistentDict
()
root
[
"index"
]
=
index
=
PersistentDict
()
real_data
[
"a"
]
=
PersistentDict
({
"indexed_value"
:
False
})
real_data
[
"b"
]
=
PersistentDict
({
"indexed_value"
:
True
})
index
[
True
]
=
PersistentDict
({
"b"
:
1
})
index
[
False
]
=
PersistentDict
({
"a"
:
1
})
real_data
[
"a"
]
=
PersistentDict
({
"indexed_value"
:
0
})
real_data
[
"b"
]
=
PersistentDict
({
"indexed_value"
:
1
})
index
[
1
]
=
PersistentDict
({
"b"
:
1
})
index
[
0
]
=
PersistentDict
({
"a"
:
1
})
get_transaction
().
commit
()
# load some objects from one connection
...
...
@@ -251,8 +251,8 @@ class ZODBTests(unittest.TestCase):
index2
=
r2
[
"index"
]
real_data
[
"b"
][
"indexed_value"
]
=
False
del
index
[
True
][
"b"
]
index
[
False
][
"b"
]
=
1
del
index
[
1
][
"b"
]
index
[
0
][
"b"
]
=
1
cn2
.
getTransaction
().
commit
()
del
real_data2
[
"a"
]
...
...
@@ -269,8 +269,8 @@ class ZODBTests(unittest.TestCase):
# index2 values not ready to commit
self
.
assert_
(
not
index2
.
_p_changed
)
self
.
assert_
(
not
index2
[
False
].
_p_changed
)
self
.
assert_
(
not
index2
[
True
].
_p_changed
)
self
.
assert_
(
not
index2
[
0
].
_p_changed
)
self
.
assert_
(
not
index2
[
1
].
_p_changed
)
self
.
assertRaises
(
ConflictError
,
get_transaction
().
commit
)
get_transaction
().
abort
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment