Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tempstorage
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
tempstorage
Commits
11d86e05
Commit
11d86e05
authored
Feb 08, 2009
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Plain Diff
Move in the real code
parents
275ea579
b4ab0403
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
518 additions
and
0 deletions
+518
-0
src/tempstorage/TemporaryStorage.py
src/tempstorage/TemporaryStorage.py
+355
-0
src/tempstorage/__init__.py
src/tempstorage/__init__.py
+1
-0
src/tempstorage/component.xml
src/tempstorage/component.xml
+14
-0
src/tempstorage/config.py
src/tempstorage/config.py
+6
-0
src/tempstorage/tests/__init__.py
src/tempstorage/tests/__init__.py
+15
-0
src/tempstorage/tests/testTemporaryStorage.py
src/tempstorage/tests/testTemporaryStorage.py
+127
-0
No files found.
src/tempstorage/TemporaryStorage.py
0 → 100644
View file @
11d86e05
This diff is collapsed.
Click to expand it.
src/tempstorage/__init__.py
0 → 100644
View file @
11d86e05
""" tempstorage package """
src/tempstorage/component.xml
0 → 100644
View file @
11d86e05
<component
prefix=
"tempstorage.config"
>
<sectiontype
name=
"temporarystorage"
datatype=
".TemporaryStorage"
implements=
"ZODB.storage"
>
<description>
A nonundoing storage which keeps data in RAM and which does
not need to be packed unless cyclic references are kept.
</description>
<key
name=
"name"
default=
"Temporary Storage"
/>
</sectiontype>
</component>
src/tempstorage/config.py
0 → 100644
View file @
11d86e05
from
ZODB.config
import
BaseConfig
class
TemporaryStorage
(
BaseConfig
):
def
open
(
self
):
from
tempstorage.TemporaryStorage
import
TemporaryStorage
return
TemporaryStorage
(
self
.
config
.
name
)
src/tempstorage/tests/__init__.py
0 → 100644
View file @
11d86e05
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
# This file is needed to make this a package.
src/tempstorage/tests/testTemporaryStorage.py
0 → 100644
View file @
11d86e05
import
ZODB
from
ZODB.tests.MinPO
import
MinPO
from
tempstorage
import
TemporaryStorage
import
sys
,
os
,
unittest
,
time
from
ZODB.tests
import
StorageTestBase
,
BasicStorage
,
\
Synchronization
,
ConflictResolution
,
\
Corruption
,
RevisionStorage
,
MTStorage
from
persistent
import
Persistent
import
transaction
from
ZODB.DB
import
DB
from
ZODB.POSException
import
ReadConflictError
class
TemporaryStorageTests
(
StorageTestBase
.
StorageTestBase
,
## RevisionStorage.RevisionStorage, # not a revision storage, but passes
BasicStorage
.
BasicStorage
,
Synchronization
.
SynchronizedStorage
,
ConflictResolution
.
ConflictResolvingStorage
,
MTStorage
.
MTStorage
,
):
def
open
(
self
,
**
kwargs
):
self
.
_storage
=
TemporaryStorage
.
TemporaryStorage
(
'foo'
)
def
setUp
(
self
):
StorageTestBase
.
StorageTestBase
.
setUp
(
self
)
self
.
open
()
def
tearDown
(
self
):
StorageTestBase
.
StorageTestBase
.
tearDown
(
self
)
def
checkConflictCacheIsCleared
(
self
):
old_gcevery
=
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
old_maxage
=
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
=
5
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
=
5
try
:
oid
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid
,
data
=
MinPO
(
5
))
time
.
sleep
(
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
+
1
)
oid2
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid2
,
data
=
MinPO
(
10
))
oid3
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid3
,
data
=
MinPO
(
9
))
assert
len
(
self
.
_storage
.
_conflict_cache
)
==
2
time
.
sleep
(
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
+
1
)
oid4
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid4
,
data
=
MinPO
(
11
))
assert
len
(
self
.
_storage
.
_conflict_cache
)
==
1
finally
:
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
=
old_gcevery
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
=
old_maxage
def
doreadconflict
(
self
,
db
,
mvcc
):
tm1
=
transaction
.
TransactionManager
()
conn
=
db
.
open
(
transaction_manager
=
tm1
)
r1
=
conn
.
root
()
obj
=
MinPO
(
'root'
)
r1
[
"p"
]
=
obj
obj
=
r1
[
"p"
]
obj
.
child1
=
MinPO
(
'child1'
)
tm1
.
get
().
commit
()
# start a new transaction with a new connection
tm2
=
transaction
.
TransactionManager
()
cn2
=
db
.
open
(
transaction_manager
=
tm2
)
r2
=
cn2
.
root
()
self
.
assertEqual
(
r1
.
_p_serial
,
r2
.
_p_serial
)
obj
.
child2
=
MinPO
(
'child2'
)
tm1
.
get
().
commit
()
# resume the transaction using cn2
obj
=
r2
[
"p"
]
# An attempt to access obj.child1 should fail with an RCE
# below if conn isn't using mvcc, because r2 was read earlier
# in the transaction and obj was modified by the other
# transaction.
obj
.
child1
return
obj
def
checkWithMVCCDoesntRaiseReadConflict
(
self
):
db
=
DB
(
self
.
_storage
)
ob
=
self
.
doreadconflict
(
db
,
True
)
self
.
assertEquals
(
ob
.
__class__
,
MinPO
)
self
.
assertEquals
(
getattr
(
ob
,
'child1'
,
MinPO
()).
value
,
'child1'
)
self
.
failIf
(
getattr
(
ob
,
'child2'
,
None
))
def
checkLoadEx
(
self
):
oid
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid
,
data
=
MinPO
(
1
))
loadp
,
loads
=
self
.
_storage
.
load
(
oid
,
'whatever'
)
exp
,
exs
,
exv
=
self
.
_storage
.
loadEx
(
oid
,
'whatever'
)
self
.
assertEqual
(
loadp
,
exp
)
self
.
assertEqual
(
loads
,
exs
)
self
.
assertEqual
(
exv
,
''
)
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
(
verbosity
=
9
)
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