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
58769030
Commit
58769030
authored
May 14, 2010
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverted a premature commit
parent
7ee7c920
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
70 deletions
+13
-70
src/CHANGES.txt
src/CHANGES.txt
+0
-5
src/ZEO/StorageServer.py
src/ZEO/StorageServer.py
+0
-1
src/ZODB/ConflictResolution.py
src/ZODB/ConflictResolution.py
+5
-11
src/ZODB/DB.py
src/ZODB/DB.py
+0
-2
src/ZODB/interfaces.py
src/ZODB/interfaces.py
+8
-33
src/ZODB/tests/ConflictResolution.py
src/ZODB/tests/ConflictResolution.py
+0
-18
No files found.
src/CHANGES.txt
View file @
58769030
...
@@ -32,11 +32,6 @@ New Features
...
@@ -32,11 +32,6 @@ New Features
- You can now pass None (rather than a storage or file name) to get
- You can now pass None (rather than a storage or file name) to get
a database with a mapping storage.
a database with a mapping storage.
- Renamed IStorageDB to IStorageWrapper and expanded it to provide
methods for transforming and untransforming data records. This was
needed to make storage wrappers that transform data work with
conflict resolution.
Bugs Fixed
Bugs Fixed
----------
----------
...
...
src/ZEO/StorageServer.py
View file @
58769030
...
@@ -778,7 +778,6 @@ class StorageServerDB:
...
@@ -778,7 +778,6 @@ class StorageServerDB:
def
invalidateCache
(
self
):
def
invalidateCache
(
self
):
self
.
server
.
_invalidateCache
(
self
.
storage_id
)
self
.
server
.
_invalidateCache
(
self
.
storage_id
)
transform_record_data
=
untransform_record_data
=
lambda
self
,
data
:
data
class
StorageServer
:
class
StorageServer
:
...
...
src/ZODB/ConflictResolution.py
View file @
58769030
...
@@ -53,7 +53,6 @@ def find_global(*args):
...
@@ -53,7 +53,6 @@ def find_global(*args):
def
state
(
self
,
oid
,
serial
,
prfactory
,
p
=
''
):
def
state
(
self
,
oid
,
serial
,
prfactory
,
p
=
''
):
p
=
p
or
self
.
loadSerial
(
oid
,
serial
)
p
=
p
or
self
.
loadSerial
(
oid
,
serial
)
p
=
self
.
_crs_wrapper
.
untransform_record_data
(
p
)
file
=
StringIO
(
p
)
file
=
StringIO
(
p
)
unpickler
=
Unpickler
(
file
)
unpickler
=
Unpickler
(
file
)
unpickler
.
find_global
=
find_global
unpickler
.
find_global
=
find_global
...
@@ -180,7 +179,6 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
...
@@ -180,7 +179,6 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
# class_tuple, old, committed, newstate = ('',''), 0, 0, 0
# class_tuple, old, committed, newstate = ('',''), 0, 0, 0
try
:
try
:
prfactory
=
PersistentReferenceFactory
()
prfactory
=
PersistentReferenceFactory
()
newpickle
=
self
.
_crs_wrapper
.
untransform_record_data
(
newpickle
)
file
=
StringIO
(
newpickle
)
file
=
StringIO
(
newpickle
)
unpickler
=
Unpickler
(
file
)
unpickler
=
Unpickler
(
file
)
unpickler
.
find_global
=
find_global
unpickler
.
find_global
=
find_global
...
@@ -217,7 +215,7 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
...
@@ -217,7 +215,7 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
pickler
.
inst_persistent_id
=
persistent_id
pickler
.
inst_persistent_id
=
persistent_id
pickler
.
dump
(
meta
)
pickler
.
dump
(
meta
)
pickler
.
dump
(
resolved
)
pickler
.
dump
(
resolved
)
return
self
.
_crs_wrapper
.
transform_record_data
(
file
.
getvalue
(
1
)
)
return
file
.
getvalue
(
1
)
except
(
ConflictError
,
BadClassName
):
except
(
ConflictError
,
BadClassName
):
return
None
return
None
except
:
except
:
...
@@ -229,11 +227,7 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
...
@@ -229,11 +227,7 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
logger
.
error
(
"Unexpected error"
,
exc_info
=
True
)
logger
.
error
(
"Unexpected error"
,
exc_info
=
True
)
return
None
return
None
class
ConflictResolvingStorage
(
object
)
:
class
ConflictResolvingStorage
:
"Mix-in class that provides conflict resolution handling for storages"
"Mix-in class that provides conflict resolution handling for storages"
tryToResolveConflict
=
tryToResolveConflict
tryToResolveConflict
=
tryToResolveConflict
def
registerDB
(
self
,
wrapper
):
self
.
_crs_wrapper
=
wrapper
super
(
ConflictResolvingStorage
,
self
).
registerDB
(
wrapper
)
src/ZODB/DB.py
View file @
58769030
...
@@ -705,8 +705,6 @@ class DB(object):
...
@@ -705,8 +705,6 @@ class DB(object):
"""
"""
self
.
_connectionMap
(
lambda
c
:
c
.
invalidateCache
())
self
.
_connectionMap
(
lambda
c
:
c
.
invalidateCache
())
transform_record_data
=
untransform_record_data
=
lambda
self
,
data
:
data
def
objectCount
(
self
):
def
objectCount
(
self
):
return
len
(
self
.
storage
)
return
len
(
self
.
storage
)
...
...
src/ZODB/interfaces.py
View file @
58769030
...
@@ -287,32 +287,23 @@ class IConnection(Interface):
...
@@ -287,32 +287,23 @@ class IConnection(Interface):
"""
"""
class
IStorage
Wrapper
(
Interface
):
class
IStorage
DB
(
Interface
):
"""
Storage wrapper interface
"""
Database interface exposed to storages
This interface provides
3
facilities:
This interface provides
2
facilities:
- Out-of-band invalidation support
- Out-of-band invalidation support
A storage can notify it's
wrapper
of object invalidations that
A storage can notify it's
database
of object invalidations that
don't occur due to direct operations on the storage. Currently
don't occur due to direct operations on the storage. Currently
this is only used by ZEO client storages to pass invalidation
this is only used by ZEO client storages to pass invalidation
messages sent from a server.
messages sent from a server.
- Record-reference extraction
- Record-reference extraction
.
The references method can be used to extract referenced object
The references method can be used to extract referenced object
IDs from a database record. This can be used by storages to
IDs from a database record. This can be used by storages to
provide more advanced garbage collection. A wrapper storage
provide more advanced garbage collection.
that transforms data will provide a references method that
untransforms data passed to it and then pass the data to the
layer above it.
- Record transformation
A storage wrapper may transform data, for example for
compression or encryption. Methods are provided to transform or
untransform data.
This interface may be implemented by storage adapters or other
This interface may be implemented by storage adapters or other
intermediaries. For example, a storage adapter that provides
intermediaries. For example, a storage adapter that provides
...
@@ -346,16 +337,6 @@ class IStorageWrapper(Interface):
...
@@ -346,16 +337,6 @@ class IStorageWrapper(Interface):
be created and returned.
be created and returned.
"""
"""
def
transform_record_data
(
data
):
"""Return transformed data
"""
def
untransform_record_data
(
data
):
"""Return untransformed data
"""
IStorageDB
=
IStorageWrapper
# for backward compatibility
class
IDatabase
(
IStorageDB
):
class
IDatabase
(
IStorageDB
):
"""ZODB DB.
"""ZODB DB.
...
@@ -614,18 +595,12 @@ class IStorage(Interface):
...
@@ -614,18 +595,12 @@ class IStorage(Interface):
revisions.
revisions.
"""
"""
def
registerDB
(
wrapper
):
def
registerDB
(
db
):
"""Register a storage wrapper IStorageWrapper.
"""Register an IStorageDB.
The passed object is a wrapper object that provides an upcall
interface to support composition.
Note that, for historical reasons, an implementation may
Note that, for historical reasons, an implementation may
require a second argument, however, if required, the None will
require a second argument, however, if required, the None will
be passed as the second argument.
be passed as the second argument.
Also, for historical reasons, this is called registerDB rather
than register_wrapper.
"""
"""
def
sortKey
():
def
sortKey
():
...
...
src/ZODB/tests/ConflictResolution.py
View file @
58769030
...
@@ -53,15 +53,9 @@ class PCounter4(PCounter):
...
@@ -53,15 +53,9 @@ class PCounter4(PCounter):
def
_p_resolveConflict
(
self
,
oldState
,
savedState
):
def
_p_resolveConflict
(
self
,
oldState
,
savedState
):
raise
RuntimeError
(
"Can't get here; not enough args"
)
raise
RuntimeError
(
"Can't get here; not enough args"
)
class
StorageWrapper
:
transform_record_data
=
untransform_record_data
=
lambda
self
,
data
:
data
class
ConflictResolvingStorage
:
class
ConflictResolvingStorage
:
def
checkResolve
(
self
):
def
checkResolve
(
self
):
self
.
_storage
.
registerDB
(
StorageWrapper
())
obj
=
PCounter
()
obj
=
PCounter
()
obj
.
inc
()
obj
.
inc
()
...
@@ -82,8 +76,6 @@ class ConflictResolvingStorage:
...
@@ -82,8 +76,6 @@ class ConflictResolvingStorage:
self
.
assertEqual
(
inst
.
_value
,
5
)
self
.
assertEqual
(
inst
.
_value
,
5
)
def
checkUnresolvable
(
self
):
def
checkUnresolvable
(
self
):
self
.
_storage
.
registerDB
(
StorageWrapper
())
obj
=
PCounter2
()
obj
=
PCounter2
()
obj
.
inc
()
obj
.
inc
()
...
@@ -105,15 +97,11 @@ class ConflictResolvingStorage:
...
@@ -105,15 +97,11 @@ class ConflictResolvingStorage:
self
.
fail
(
"Expected ConflictError"
)
self
.
fail
(
"Expected ConflictError"
)
def
checkZClassesArentResolved
(
self
):
def
checkZClassesArentResolved
(
self
):
self
.
_storage
.
registerDB
(
StorageWrapper
())
from
ZODB.ConflictResolution
import
find_global
,
BadClassName
from
ZODB.ConflictResolution
import
find_global
,
BadClassName
dummy_class_tuple
=
(
'*foobar'
,
())
dummy_class_tuple
=
(
'*foobar'
,
())
self
.
assertRaises
(
BadClassName
,
find_global
,
'*foobar'
,
())
self
.
assertRaises
(
BadClassName
,
find_global
,
'*foobar'
,
())
def
checkBuggyResolve1
(
self
):
def
checkBuggyResolve1
(
self
):
self
.
_storage
.
registerDB
(
StorageWrapper
())
obj
=
PCounter3
()
obj
=
PCounter3
()
obj
.
inc
()
obj
.
inc
()
...
@@ -132,8 +120,6 @@ class ConflictResolvingStorage:
...
@@ -132,8 +120,6 @@ class ConflictResolvingStorage:
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
def
checkBuggyResolve2
(
self
):
def
checkBuggyResolve2
(
self
):
self
.
_storage
.
registerDB
(
StorageWrapper
())
obj
=
PCounter4
()
obj
=
PCounter4
()
obj
.
inc
()
obj
.
inc
()
...
@@ -158,8 +144,6 @@ class ConflictResolvingTransUndoStorage:
...
@@ -158,8 +144,6 @@ class ConflictResolvingTransUndoStorage:
# TransactionalUndoStorage test suite. Except here, conflict
# TransactionalUndoStorage test suite. Except here, conflict
# resolution should allow us to undo the transaction anyway.
# resolution should allow us to undo the transaction anyway.
self
.
_storage
.
registerDB
(
StorageWrapper
())
obj
=
PCounter
()
obj
=
PCounter
()
obj
.
inc
()
obj
.
inc
()
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
...
@@ -182,8 +166,6 @@ class ConflictResolvingTransUndoStorage:
...
@@ -182,8 +166,6 @@ class ConflictResolvingTransUndoStorage:
# TransactionalUndoStorage test suite. Except here, conflict
# TransactionalUndoStorage test suite. Except here, conflict
# resolution should allow us to undo the transaction anyway.
# resolution should allow us to undo the transaction anyway.
self
.
_storage
.
registerDB
(
StorageWrapper
())
obj
=
PCounter2
()
obj
=
PCounter2
()
obj
.
inc
()
obj
.
inc
()
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
...
...
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