Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
e1a00cbf
Commit
e1a00cbf
authored
Nov 17, 2001
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disabled conflict resolution for sake of stability. Stress tests now pass as a result.
parent
f3b4033d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
35 deletions
+82
-35
lib/python/Products/TemporaryFolder/TemporaryStorage.py
lib/python/Products/TemporaryFolder/TemporaryStorage.py
+28
-35
lib/python/Products/TemporaryFolder/tests/testTemporaryStorage.py
...on/Products/TemporaryFolder/tests/testTemporaryStorage.py
+54
-0
No files found.
lib/python/Products/TemporaryFolder/TemporaryStorage.py
View file @
e1a00cbf
...
...
@@ -85,27 +85,20 @@
"""
A storage implementation which uses RAM to persist objects, much like
MappingStorage
, but unlike MappingStorage
needs not be packed to get rid of
MappingStorage
. Unlike MappingStorage, it
needs not be packed to get rid of
non-cyclic garbage. This is a ripoff of Jim's Packless bsddb3 storage.
$Id: TemporaryStorage.py,v 1.
2 2001/11/13 21:44:33 matt
Exp $
$Id: TemporaryStorage.py,v 1.
3 2001/11/17 22:50:31 chrism
Exp $
"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
from
zLOG
import
LOG
from
struct
import
pack
,
unpack
from
ZODB.referencesf
import
referencesf
from
ZODB
import
POSException
from
ZODB.BaseStorage
import
BaseStorage
try
:
from
ZODB.ConflictResolution
import
ConflictResolvingStorage
except
:
LOG
(
'Temporary Storage'
,
100
,
(
'Not able to use ConflictResolvingStorage for TemporaryStorage, '
'this is suboptimal. Upgrade to Zope 2.3.2 or later to '
'make use of conflict resolution.'
))
class
ConflictResolvingStorage
:
pass
from
ZODB.ConflictResolution
import
ConflictResolvingStorage
,
ResolvedSerial
class
ReferenceCountError
(
POSException
.
POSError
):
""" An error occured while decrementing a reference to an object in
...
...
@@ -117,7 +110,7 @@ class TemporaryStorageError(POSException.POSError):
available tempfile space and RAM consumption and restart the server
process."""
class
TemporaryStorage
(
BaseStorage
,
ConflictResolvingStorage
):
class
TemporaryStorage
(
BaseStorage
):
#
, ConflictResolvingStorage):
def
__init__
(
self
,
name
=
'TemporaryStorage'
):
"""
...
...
@@ -158,40 +151,40 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
finally
:
self
.
_lock_release
()
def
loadSerial
(
self
,
oid
,
serial
):
""" only a stub to make conflict resolution work! """
self
.
_lock_acquire
()
try
:
return
self
.
_opickle
[
oid
]
finally
:
self
.
_lock_release
()
## This loadSerial doesn't work for resolution of conficts. :-( I
## haven't figured out why that's the case. As a result, I'm disabling
## conflict resolution in the storage until I have time to figure out why.
## def loadSerial(self, oid, serial):
## """ only a stub to make conflict resolution work! """
## self._lock_acquire()
## try:
## return self._opickle[oid]
## finally:
## self._lock_release()
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
if
transaction
is
not
self
.
_transaction
:
raise
POSException
.
StorageTransactionError
(
self
,
transaction
)
if
version
:
raise
POSException
.
Unsupported
,
(
"TemporaryStorage is incompatible "
"
with versions"
,)
raise
POSException
.
Unsupported
,
(
"
TemporaryStorage is incompatible with versions"
)
self
.
_lock_acquire
()
try
:
if
self
.
_index
.
has_key
(
oid
):
oserial
=
self
.
_index
[
oid
]
if
serial
!=
oserial
:
if
hasattr
(
self
,
'tryToResolveConflict'
):
data
=
self
.
tryToResolveConflict
(
oid
,
oserial
,
serial
,
data
)
if
not
data
:
raise
POSException
.
ConflictError
,
(
serial
,
oserial
)
else
:
raise
POSException
.
ConflictError
,
(
serial
,
oserial
)
serial
=
self
.
_serial
raise
POSException
.
ConflictError
,
(
serial
,
oserial
)
## data=self.tryToResolveConflict(oid, oserial, serial, data)
## if not data:
## raise POSException.ConflictError, (serial,oserial)
else
:
oserial
=
serial
newserial
=
self
.
_serial
self
.
_tmp
.
append
((
oid
,
data
))
return
serial
## return serial == oserial and newserial or ResolvedSerial
return
newserial
finally
:
self
.
_lock_release
()
...
...
lib/python/Products/TemporaryFolder/tests/testTemporaryStorage.py
0 → 100644
View file @
e1a00cbf
if
__name__
==
'__main__'
:
import
sys
sys
.
path
.
insert
(
0
,
'../../..'
)
sys
.
path
.
insert
(
0
,
'..'
)
import
ZODB
from
Products.TemporaryFolder
import
TemporaryStorage
import
sys
,
os
,
unittest
from
ZODB.tests
import
StorageTestBase
,
BasicStorage
,
\
Synchronization
,
ConflictResolution
,
\
Corruption
,
RevisionStorage
class
TemporaryStorageTests
(
StorageTestBase
.
StorageTestBase
,
BasicStorage
.
BasicStorage
,
Synchronization
.
SynchronizedStorage
,
#ConflictResolution.ConflictResolvingStorage,
#RevisionStorage.RevisionStorage
):
def
open
(
self
,
**
kwargs
):
self
.
_storage
=
TemporaryStorage
.
TemporaryStorage
(
'foo'
)
def
setUp
(
self
):
self
.
open
()
StorageTestBase
.
StorageTestBase
.
setUp
(
self
)
def
tearDown
(
self
):
StorageTestBase
.
StorageTestBase
.
tearDown
(
self
)
def
test_suite
():
suite
=
unittest
.
makeSuite
(
TemporaryStorageTests
,
'check'
)
suite2
=
unittest
.
makeSuite
(
Corruption
.
FileStorageCorruptTests
,
'check'
)
suite
.
addTest
(
suite2
)
return
suite
def
main
():
alltests
=
test_suite
()
runner
=
unittest
.
TextTestRunner
()
runner
.
run
(
alltests
)
def
debug
():
test_suite
().
debug
()
def
pdebug
():
import
pdb
pdb
.
run
(
'debug()'
)
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>
1
:
globals
()[
sys
.
argv
[
1
]]()
else
:
main
()
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