Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
ZEO
Commits
3725dd74
Commit
3725dd74
authored
Jul 27, 1999
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added quota option.
parent
b3805a2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
+25
-3
src/ZODB/DemoStorage.py
src/ZODB/DemoStorage.py
+25
-3
No files found.
src/ZODB/DemoStorage.py
View file @
3725dd74
...
...
@@ -150,7 +150,7 @@ method::
and call it to minotor the storage.
"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
base64
,
POSException
,
BTree
,
BaseStorage
,
time
,
string
,
utils
from
TimeStamp
import
TimeStamp
...
...
@@ -158,16 +158,18 @@ from cPickle import loads
class
DemoStorage
(
BaseStorage
.
BaseStorage
):
def
__init__
(
self
,
name
=
'Demo Storage'
,
base
=
None
):
def
__init__
(
self
,
name
=
'Demo Storage'
,
base
=
None
,
quota
=
None
):
BaseStorage
.
BaseStorage
.
__init__
(
self
,
name
,
base
)
# We use a BTree because the items are sorted!
self
.
_data
=
BTree
.
BTree
()
self
.
_index
=
{}
self
.
_tindex
=
[]
self
.
_vindex
=
{}
self
.
_base
=
base
self
.
_size
=
0
self
.
_quota
=
quota
self
.
_clear_temp
()
if
base
is
not
None
and
base
.
versions
():
raise
POSException
.
StorageError
,
(
"Demo base storage has version data"
)
...
...
@@ -190,6 +192,7 @@ class DemoStorage(BaseStorage.BaseStorage):
for
v
in
self
.
_vindex
.
values
():
s
=
s
+
32
+
16
*
len
(
v
)
self
.
_size
=
s
return
s
def
abortVersion
(
self
,
src
,
transaction
):
...
...
@@ -297,6 +300,17 @@ class DemoStorage(BaseStorage.BaseStorage):
serial
=
self
.
_serial
r
=
[
oid
,
serial
,
old
,
version
and
(
version
,
nv
)
or
None
,
data
]
self
.
_tindex
.
append
(
r
)
s
=
self
.
_tsize
s
=
s
+
72
+
(
data
and
(
16
+
len
(
data
))
or
4
)
if
version
:
s
=
s
+
32
+
len
(
version
)
if
s
>
self
.
_quota
:
raise
POSException
.
StorageError
,
(
'''<b>Quota Exceeded</b><br>
The maximum quota for this demonstration storage
has been exceeded.<br>Have a nice day.'''
)
finally
:
self
.
_lock_release
()
return
serial
...
...
@@ -305,12 +319,19 @@ class DemoStorage(BaseStorage.BaseStorage):
def
_clear_temp
(
self
):
self
.
_tindex
=
[]
self
.
_tsize
=
self
.
_size
+
160
def
_begin
(
self
,
tid
,
u
,
d
,
e
):
self
.
_tsize
=
self
.
_size
+
120
+
len
(
u
)
+
len
(
d
)
+
len
(
e
)
def
_finish
(
self
,
tid
,
user
,
desc
,
ext
):
index
=
self
.
_index
tindex
=
self
.
_tindex
vindex
=
self
.
_vindex
self
.
_size
=
self
.
_tsize
self
.
_data
[
tid
]
=
None
,
user
,
desc
,
ext
,
tuple
(
tindex
)
for
r
in
tindex
:
oid
,
serial
,
pre
,
vdata
,
p
=
r
...
...
@@ -547,6 +568,7 @@ class DemoStorage(BaseStorage.BaseStorage):
self
.
_index
,
self
.
_vindex
=
self
.
_build_indexes
()
finally
:
self
.
_lock_release
()
self
.
getSize
()
def
_splat
(
self
):
"""Spit out a string showing state.
...
...
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