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
bc40c6a3
Commit
bc40c6a3
authored
Aug 14, 2002
by
Martijn Pieters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up indentation and trailing whitespace.
parent
9677fe8e
Changes
57
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
57 changed files
with
511 additions
and
529 deletions
+511
-529
trunk/src/Persistence/PersistentList.py
trunk/src/Persistence/PersistentList.py
+8
-8
trunk/src/Persistence/PersistentMapping.py
trunk/src/Persistence/PersistentMapping.py
+5
-5
trunk/src/ZODB/ActivityMonitor.py
trunk/src/ZODB/ActivityMonitor.py
+4
-5
trunk/src/ZODB/BaseStorage.py
trunk/src/ZODB/BaseStorage.py
+14
-14
trunk/src/ZODB/ConflictResolution.py
trunk/src/ZODB/ConflictResolution.py
+2
-2
trunk/src/ZODB/Connection.py
trunk/src/ZODB/Connection.py
+37
-38
trunk/src/ZODB/DB.py
trunk/src/ZODB/DB.py
+24
-24
trunk/src/ZODB/DemoStorage.py
trunk/src/ZODB/DemoStorage.py
+36
-36
trunk/src/ZODB/ExportImport.py
trunk/src/ZODB/ExportImport.py
+4
-5
trunk/src/ZODB/FileStorage.py
trunk/src/ZODB/FileStorage.py
+114
-114
trunk/src/ZODB/MappingStorage.py
trunk/src/ZODB/MappingStorage.py
+12
-12
trunk/src/ZODB/Mount.py
trunk/src/ZODB/Mount.py
+6
-6
trunk/src/ZODB/POSException.py
trunk/src/ZODB/POSException.py
+5
-5
trunk/src/ZODB/PersistentList.py
trunk/src/ZODB/PersistentList.py
+8
-8
trunk/src/ZODB/PersistentMapping.py
trunk/src/ZODB/PersistentMapping.py
+5
-5
trunk/src/ZODB/TmpStore.py
trunk/src/ZODB/TmpStore.py
+5
-5
trunk/src/ZODB/Transaction.py
trunk/src/ZODB/Transaction.py
+21
-22
trunk/src/ZODB/UndoLogCompatible.py
trunk/src/ZODB/UndoLogCompatible.py
+3
-3
trunk/src/ZODB/ZApplication.py
trunk/src/ZODB/ZApplication.py
+9
-10
trunk/src/ZODB/__init__.py
trunk/src/ZODB/__init__.py
+2
-2
trunk/src/ZODB/bpthread.py
trunk/src/ZODB/bpthread.py
+3
-3
trunk/src/ZODB/conversionhack.py
trunk/src/ZODB/conversionhack.py
+2
-2
trunk/src/ZODB/dbmStorage.py
trunk/src/ZODB/dbmStorage.py
+8
-8
trunk/src/ZODB/fsIndex.py
trunk/src/ZODB/fsIndex.py
+9
-9
trunk/src/ZODB/fsrecover.py
trunk/src/ZODB/fsrecover.py
+11
-12
trunk/src/ZODB/lock_file.py
trunk/src/ZODB/lock_file.py
+4
-5
trunk/src/ZODB/referencesf.py
trunk/src/ZODB/referencesf.py
+2
-2
trunk/src/ZODB/tests/BasicStorage.py
trunk/src/ZODB/tests/BasicStorage.py
+1
-1
trunk/src/ZODB/tests/ConflictResolution.py
trunk/src/ZODB/tests/ConflictResolution.py
+7
-8
trunk/src/ZODB/tests/Corruption.py
trunk/src/ZODB/tests/Corruption.py
+2
-2
trunk/src/ZODB/tests/HistoryStorage.py
trunk/src/ZODB/tests/HistoryStorage.py
+1
-1
trunk/src/ZODB/tests/IteratorStorage.py
trunk/src/ZODB/tests/IteratorStorage.py
+1
-1
trunk/src/ZODB/tests/MTStorage.py
trunk/src/ZODB/tests/MTStorage.py
+2
-3
trunk/src/ZODB/tests/PackableStorage.py
trunk/src/ZODB/tests/PackableStorage.py
+5
-5
trunk/src/ZODB/tests/PersistentStorage.py
trunk/src/ZODB/tests/PersistentStorage.py
+2
-2
trunk/src/ZODB/tests/ReadOnlyStorage.py
trunk/src/ZODB/tests/ReadOnlyStorage.py
+1
-3
trunk/src/ZODB/tests/RevisionStorage.py
trunk/src/ZODB/tests/RevisionStorage.py
+1
-2
trunk/src/ZODB/tests/StorageTestBase.py
trunk/src/ZODB/tests/StorageTestBase.py
+6
-6
trunk/src/ZODB/tests/Synchronization.py
trunk/src/ZODB/tests/Synchronization.py
+5
-5
trunk/src/ZODB/tests/TransactionalUndoStorage.py
trunk/src/ZODB/tests/TransactionalUndoStorage.py
+2
-2
trunk/src/ZODB/tests/TransactionalUndoVersionStorage.py
trunk/src/ZODB/tests/TransactionalUndoVersionStorage.py
+4
-5
trunk/src/ZODB/tests/VersionStorage.py
trunk/src/ZODB/tests/VersionStorage.py
+7
-7
trunk/src/ZODB/tests/speed.py
trunk/src/ZODB/tests/speed.py
+6
-6
trunk/src/ZODB/tests/testActivityMonitor.py
trunk/src/ZODB/tests/testActivityMonitor.py
+3
-3
trunk/src/ZODB/tests/testCache.py
trunk/src/ZODB/tests/testCache.py
+5
-5
trunk/src/ZODB/tests/testDB.py
trunk/src/ZODB/tests/testDB.py
+0
-1
trunk/src/ZODB/tests/testDemoStorage.py
trunk/src/ZODB/tests/testDemoStorage.py
+0
-1
trunk/src/ZODB/tests/testFileStorage.py
trunk/src/ZODB/tests/testFileStorage.py
+6
-6
trunk/src/ZODB/tests/testMappingStorage.py
trunk/src/ZODB/tests/testMappingStorage.py
+0
-1
trunk/src/ZODB/tests/testPersistentMapping.py
trunk/src/ZODB/tests/testPersistentMapping.py
+1
-1
trunk/src/ZODB/tests/testTransaction.py
trunk/src/ZODB/tests/testTransaction.py
+53
-53
trunk/src/ZODB/tests/testUtils.py
trunk/src/ZODB/tests/testUtils.py
+2
-3
trunk/src/ZODB/tests/testZODB.py
trunk/src/ZODB/tests/testZODB.py
+6
-6
trunk/src/ZODB/tests/testfsIndex.py
trunk/src/ZODB/tests/testfsIndex.py
+3
-4
trunk/src/ZODB/utils.py
trunk/src/ZODB/utils.py
+3
-3
trunk/src/persistent/list.py
trunk/src/persistent/list.py
+8
-8
trunk/src/persistent/mapping.py
trunk/src/persistent/mapping.py
+5
-5
No files found.
trunk/src/Persistence/PersistentList.py
View file @
bc40c6a3
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python implementation of persistent list.
"""Python implementation of persistent list.
$Id: PersistentList.py,v 1.
2 2002/02/11 23:49:07 gvanrossum
Exp $"""
$Id: PersistentList.py,v 1.
3 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
from
UserList
import
UserList
from
UserList
import
UserList
...
@@ -51,7 +51,7 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -51,7 +51,7 @@ class PersistentList(UserList, Persistence.Persistent):
def
__delslice__
(
self
,
i
,
j
):
def
__delslice__
(
self
,
i
,
j
):
self
.
__super_delslice
(
i
,
j
)
self
.
__super_delslice
(
i
,
j
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
__iadd__
(
self
,
other
):
def
__iadd__
(
self
,
other
):
self
.
__super_iadd
(
other
)
self
.
__super_iadd
(
other
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
@@ -63,7 +63,7 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -63,7 +63,7 @@ class PersistentList(UserList, Persistence.Persistent):
def
append
(
self
,
item
):
def
append
(
self
,
item
):
self
.
__super_append
(
item
)
self
.
__super_append
(
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
insert
(
self
,
i
,
item
):
def
insert
(
self
,
i
,
item
):
self
.
__super_insert
(
i
,
item
)
self
.
__super_insert
(
i
,
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
@@ -76,11 +76,11 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -76,11 +76,11 @@ class PersistentList(UserList, Persistence.Persistent):
def
remove
(
self
,
item
):
def
remove
(
self
,
item
):
self
.
__super_remove
(
item
)
self
.
__super_remove
(
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
reverse
(
self
):
def
reverse
(
self
):
self
.
__super_reverse
()
self
.
__super_reverse
()
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
sort
(
self
,
*
args
):
def
sort
(
self
,
*
args
):
self
.
__super_sort
(
*
args
)
self
.
__super_sort
(
*
args
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
...
trunk/src/Persistence/PersistentMapping.py
View file @
bc40c6a3
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python implementation of persistent base types
"""Python implementation of persistent base types
$Id: PersistentMapping.py,v 1.
19 2002/02/12 22:33:08 gvanrossum
Exp $"""
$Id: PersistentMapping.py,v 1.
20 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.
19
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
20
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
from
UserDict
import
UserDict
from
UserDict
import
UserDict
...
@@ -82,7 +82,7 @@ class PersistentMapping(UserDict, Persistence.Persistent):
...
@@ -82,7 +82,7 @@ class PersistentMapping(UserDict, Persistence.Persistent):
# different versions of the code. Compatibility works in both
# different versions of the code. Compatibility works in both
# directions, because an application may want to share a database
# directions, because an application may want to share a database
# between applications using different versions of the code.
# between applications using different versions of the code.
# Effectively, the original rep is part of the "API." To provide
# Effectively, the original rep is part of the "API." To provide
# full compatibility, the getstate and setstate must read and
# full compatibility, the getstate and setstate must read and
# right objects using the old rep.
# right objects using the old rep.
...
...
trunk/src/ZODB/ActivityMonitor.py
View file @
bc40c6a3
...
@@ -2,19 +2,19 @@
...
@@ -2,19 +2,19 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""ZODB transfer activity monitoring
"""ZODB transfer activity monitoring
$Id: ActivityMonitor.py,v 1.
2 2002/06/10 20:20:44 shane
Exp $"""
$Id: ActivityMonitor.py,v 1.
3 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
time
import
time
...
@@ -104,4 +104,3 @@ class ActivityMonitor:
...
@@ -104,4 +104,3 @@ class ActivityMonitor:
div
[
'loads'
]
=
div
[
'loads'
]
+
total_loads
div
[
'loads'
]
=
div
[
'loads'
]
+
total_loads
return
res
return
res
trunk/src/ZODB/BaseStorage.py
View file @
bc40c6a3
...
@@ -2,20 +2,20 @@
...
@@ -2,20 +2,20 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Handy standard storage machinery
"""Handy standard storage machinery
"""
"""
# Do this portably in the face of checking out with -kv
# Do this portably in the face of checking out with -kv
import
string
import
string
__version__
=
string
.
split
(
'$Revision: 1.
19
$'
)[
-
2
:][
0
]
__version__
=
string
.
split
(
'$Revision: 1.
20
$'
)[
-
2
:][
0
]
import
ThreadLock
,
bpthread
import
ThreadLock
,
bpthread
import
time
,
UndoLogCompatible
import
time
,
UndoLogCompatible
...
@@ -30,7 +30,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
...
@@ -30,7 +30,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
_is_read_only
=
0
_is_read_only
=
0
def
__init__
(
self
,
name
,
base
=
None
):
def
__init__
(
self
,
name
,
base
=
None
):
self
.
__name__
=
name
self
.
__name__
=
name
# Allocate locks:
# Allocate locks:
...
@@ -64,13 +64,13 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
...
@@ -64,13 +64,13 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
def
getName
(
self
):
def
getName
(
self
):
return
self
.
__name__
return
self
.
__name__
def
getSize
(
self
):
def
getSize
(
self
):
return
len
(
self
)
*
300
# WAG!
return
len
(
self
)
*
300
# WAG!
def
history
(
self
,
oid
,
version
,
length
=
1
):
def
history
(
self
,
oid
,
version
,
length
=
1
):
pass
pass
def
modifiedInVersion
(
self
,
oid
):
def
modifiedInVersion
(
self
,
oid
):
return
''
return
''
...
@@ -97,13 +97,13 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
...
@@ -97,13 +97,13 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
def
isReadOnly
(
self
):
def
isReadOnly
(
self
):
return
self
.
_is_read_only
return
self
.
_is_read_only
def
supportsUndo
(
self
):
def
supportsUndo
(
self
):
return
0
return
0
def
supportsVersions
(
self
):
def
supportsVersions
(
self
):
return
0
return
0
def
tpc_abort
(
self
,
transaction
):
def
tpc_abort
(
self
,
transaction
):
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
...
@@ -147,7 +147,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
...
@@ -147,7 +147,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
self
.
_tstatus
=
status
self
.
_tstatus
=
status
self
.
_begin
(
self
.
_serial
,
user
,
desc
,
ext
)
self
.
_begin
(
self
.
_serial
,
user
,
desc
,
ext
)
finally
:
self
.
_lock_release
()
finally
:
self
.
_lock_release
()
def
_begin
(
self
,
tid
,
u
,
d
,
e
):
def
_begin
(
self
,
tid
,
u
,
d
,
e
):
...
@@ -247,7 +247,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
...
@@ -247,7 +247,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
else
:
else
:
restoring
=
0
restoring
=
0
for
transaction
in
other
.
iterator
():
for
transaction
in
other
.
iterator
():
tid
=
transaction
.
tid
tid
=
transaction
.
tid
if
_ts
is
None
:
if
_ts
is
None
:
_ts
=
TimeStamp
(
tid
)
_ts
=
TimeStamp
(
tid
)
...
@@ -265,7 +265,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
...
@@ -265,7 +265,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
ok
=
1
ok
=
1
if
verbose
:
print
_ts
if
verbose
:
print
_ts
self
.
tpc_begin
(
transaction
,
tid
,
transaction
.
status
)
self
.
tpc_begin
(
transaction
,
tid
,
transaction
.
status
)
for
r
in
transaction
:
for
r
in
transaction
:
oid
=
r
.
oid
oid
=
r
.
oid
...
@@ -276,7 +276,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
...
@@ -276,7 +276,7 @@ class BaseStorage(UndoLogCompatible.UndoLogCompatible):
pre
=
preget
(
oid
,
None
)
pre
=
preget
(
oid
,
None
)
s
=
self
.
store
(
oid
,
pre
,
r
.
data
,
r
.
version
,
transaction
)
s
=
self
.
store
(
oid
,
pre
,
r
.
data
,
r
.
version
,
transaction
)
preindex
[
oid
]
=
s
preindex
[
oid
]
=
s
self
.
tpc_vote
(
transaction
)
self
.
tpc_vote
(
transaction
)
self
.
tpc_finish
(
transaction
)
self
.
tpc_finish
(
transaction
)
...
...
trunk/src/ZODB/ConflictResolution.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
from
cPickle
import
Unpickler
,
Pickler
from
cPickle
import
Unpickler
,
Pickler
...
...
trunk/src/ZODB/Connection.py
View file @
bc40c6a3
...
@@ -2,18 +2,18 @@
...
@@ -2,18 +2,18 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Database connection support
"""Database connection support
$Id: Connection.py,v 1.7
1 2002/06/14 20:25:06 jeremy
Exp $"""
$Id: Connection.py,v 1.7
2 2002/08/14 22:07:09 mj
Exp $"""
from
cPickleCache
import
PickleCache
,
MUCH_RING_CHECKING
from
cPickleCache
import
PickleCache
,
MUCH_RING_CHECKING
from
POSException
import
ConflictError
,
ReadConflictError
from
POSException
import
ConflictError
,
ReadConflictError
...
@@ -116,7 +116,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -116,7 +116,7 @@ class Connection(ExportImport.ExportImport):
def
__getitem__
(
self
,
oid
,
tt
=
type
(())):
def
__getitem__
(
self
,
oid
,
tt
=
type
(())):
obj
=
self
.
_cache
.
get
(
oid
,
None
)
obj
=
self
.
_cache
.
get
(
oid
,
None
)
if
obj
is
not
None
:
if
obj
is
not
None
:
return
obj
return
obj
__traceback_info__
=
(
oid
)
__traceback_info__
=
(
oid
)
p
,
serial
=
self
.
_storage
.
load
(
oid
,
self
.
_version
)
p
,
serial
=
self
.
_storage
.
load
(
oid
,
self
.
_version
)
...
@@ -136,7 +136,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -136,7 +136,7 @@ class Connection(ExportImport.ExportImport):
if
type
(
klass
)
is
tt
:
if
type
(
klass
)
is
tt
:
module
,
name
=
klass
module
,
name
=
klass
klass
=
self
.
_db
.
_classFactory
(
self
,
module
,
name
)
klass
=
self
.
_db
.
_classFactory
(
self
,
module
,
name
)
if
(
args
is
None
or
if
(
args
is
None
or
not
args
and
not
hasattr
(
klass
,
'__getinitargs__'
)):
not
args
and
not
hasattr
(
klass
,
'__getinitargs__'
)):
object
=
klass
.
__basicnew__
()
object
=
klass
.
__basicnew__
()
...
@@ -152,7 +152,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -152,7 +152,7 @@ class Connection(ExportImport.ExportImport):
self
.
_cache
[
oid
]
=
object
self
.
_cache
[
oid
]
=
object
if
oid
==
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
:
if
oid
==
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
:
self
.
_root_
=
object
# keep a ref
self
.
_root_
=
object
# keep a ref
return
object
return
object
def
_persistent_load
(
self
,
oid
,
def
_persistent_load
(
self
,
oid
,
...
@@ -176,12 +176,12 @@ class Connection(ExportImport.ExportImport):
...
@@ -176,12 +176,12 @@ class Connection(ExportImport.ExportImport):
# Maybe their's more current data in the
# Maybe their's more current data in the
# object's actual record!
# object's actual record!
return
self
[
oid
]
return
self
[
oid
]
object
=
klass
.
__basicnew__
()
object
=
klass
.
__basicnew__
()
object
.
_p_oid
=
oid
object
.
_p_oid
=
oid
object
.
_p_jar
=
self
object
.
_p_jar
=
self
object
.
_p_changed
=
None
object
.
_p_changed
=
None
self
.
_cache
[
oid
]
=
object
self
.
_cache
[
oid
]
=
object
return
object
return
object
...
@@ -230,13 +230,13 @@ class Connection(ExportImport.ExportImport):
...
@@ -230,13 +230,13 @@ class Connection(ExportImport.ExportImport):
def
cacheFullSweep
(
self
,
dt
=
0
):
def
cacheFullSweep
(
self
,
dt
=
0
):
self
.
_cache
.
full_sweep
(
dt
)
self
.
_cache
.
full_sweep
(
dt
)
def
cacheMinimize
(
self
,
dt
=
0
):
def
cacheMinimize
(
self
,
dt
=
0
):
# dt is ignored
# dt is ignored
self
.
_cache
.
minimize
()
self
.
_cache
.
minimize
()
__onCloseCallbacks
=
None
__onCloseCallbacks
=
None
def
onCloseCallback
(
self
,
f
):
def
onCloseCallback
(
self
,
f
):
if
self
.
__onCloseCallbacks
is
None
:
if
self
.
__onCloseCallbacks
is
None
:
self
.
__onCloseCallbacks
=
[]
self
.
__onCloseCallbacks
=
[]
...
@@ -259,9 +259,9 @@ class Connection(ExportImport.ExportImport):
...
@@ -259,9 +259,9 @@ class Connection(ExportImport.ExportImport):
self
.
_debug_info
=
()
self
.
_debug_info
=
()
# Return the connection to the pool.
# Return the connection to the pool.
db
.
_closeConnection
(
self
)
db
.
_closeConnection
(
self
)
__onCommitActions
=
None
__onCommitActions
=
None
def
onCommitAction
(
self
,
method_name
,
*
args
,
**
kw
):
def
onCommitAction
(
self
,
method_name
,
*
args
,
**
kw
):
if
self
.
__onCommitActions
is
None
:
if
self
.
__onCommitActions
is
None
:
self
.
__onCommitActions
=
[]
self
.
__onCommitActions
=
[]
...
@@ -307,26 +307,26 @@ class Connection(ExportImport.ExportImport):
...
@@ -307,26 +307,26 @@ class Connection(ExportImport.ExportImport):
# stackup=stackup, new_oid=self.new_oid):
# stackup=stackup, new_oid=self.new_oid):
# if (not hasattr(object, '_p_oid') or
# if (not hasattr(object, '_p_oid') or
# type(object) is ClassType): return None
# type(object) is ClassType): return None
#
#
# oid=object._p_oid
# oid=object._p_oid
#
#
# if oid is None or object._p_jar is not self:
# if oid is None or object._p_jar is not self:
# oid = self.new_oid()
# oid = self.new_oid()
# object._p_jar=self
# object._p_jar=self
# object._p_oid=oid
# object._p_oid=oid
# stackup(object)
# stackup(object)
#
#
# klass=object.__class__
# klass=object.__class__
#
#
# if klass is ExtensionKlass: return oid
# if klass is ExtensionKlass: return oid
#
#
# if hasattr(klass, '__getinitargs__'): return oid
# if hasattr(klass, '__getinitargs__'): return oid
#
#
# module=getattr(klass,'__module__','')
# module=getattr(klass,'__module__','')
# if module: klass=module, klass.__name__
# if module: klass=module, klass.__name__
#
#
# return oid, klass
# return oid, klass
file
=
StringIO
()
file
=
StringIO
()
seek
=
file
.
seek
seek
=
file
.
seek
pickler
=
Pickler
(
file
,
1
)
pickler
=
Pickler
(
file
,
1
)
...
@@ -340,7 +340,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -340,7 +340,7 @@ class Connection(ExportImport.ExportImport):
version
=
self
.
_version
version
=
self
.
_version
while
stack
:
while
stack
:
object
=
stack
[
-
1
]
object
=
stack
[
-
1
]
del
stack
[
-
1
]
del
stack
[
-
1
]
...
@@ -359,9 +359,9 @@ class Connection(ExportImport.ExportImport):
...
@@ -359,9 +359,9 @@ class Connection(ExportImport.ExportImport):
):
):
raise
ConflictError
(
object
=
object
)
raise
ConflictError
(
object
=
object
)
self
.
_invalidating
.
append
(
oid
)
self
.
_invalidating
.
append
(
oid
)
klass
=
object
.
__class__
klass
=
object
.
__class__
if
klass
is
ExtensionKlass
:
if
klass
is
ExtensionKlass
:
# Yee Ha!
# Yee Ha!
dict
=
{}
dict
=
{}
...
@@ -375,12 +375,12 @@ class Connection(ExportImport.ExportImport):
...
@@ -375,12 +375,12 @@ class Connection(ExportImport.ExportImport):
len
(
args
)
# XXX Assert it's a sequence
len
(
args
)
# XXX Assert it's a sequence
else
:
else
:
args
=
None
# New no-constructor protocol!
args
=
None
# New no-constructor protocol!
module
=
getattr
(
klass
,
'__module__'
,
''
)
module
=
getattr
(
klass
,
'__module__'
,
''
)
if
module
:
klass
=
module
,
klass
.
__name__
if
module
:
klass
=
module
,
klass
.
__name__
__traceback_info__
=
klass
,
oid
,
self
.
_version
__traceback_info__
=
klass
,
oid
,
self
.
_version
state
=
object
.
__getstate__
()
state
=
object
.
__getstate__
()
seek
(
0
)
seek
(
0
)
clear_memo
()
clear_memo
()
dump
((
klass
,
args
))
dump
((
klass
,
args
))
...
@@ -409,12 +409,12 @@ class Connection(ExportImport.ExportImport):
...
@@ -409,12 +409,12 @@ class Connection(ExportImport.ExportImport):
LOG
(
'ZODB'
,
BLATHER
,
LOG
(
'ZODB'
,
BLATHER
,
'Commiting subtransaction of size %s'
%
src
.
getSize
())
'Commiting subtransaction of size %s'
%
src
.
getSize
())
self
.
_storage
=
tmp
self
.
_storage
=
tmp
self
.
_tmp
=
None
self
.
_tmp
=
None
tmp
.
tpc_begin
(
t
)
tmp
.
tpc_begin
(
t
)
load
=
src
.
load
load
=
src
.
load
store
=
tmp
.
store
store
=
tmp
.
store
dest
=
self
.
_version
dest
=
self
.
_version
...
@@ -426,7 +426,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -426,7 +426,7 @@ class Connection(ExportImport.ExportImport):
invalidating
[
len
(
invalidating
):]
=
oids
invalidating
[
len
(
invalidating
):]
=
oids
creating
=
self
.
_creating
creating
=
self
.
_creating
creating
[
len
(
creating
):]
=
src
.
_creating
creating
[
len
(
creating
):]
=
src
.
_creating
for
oid
in
oids
:
for
oid
in
oids
:
data
,
serial
=
load
(
oid
,
src
)
data
,
serial
=
load
(
oid
,
src
)
s
=
store
(
oid
,
serial
,
data
,
dest
,
t
)
s
=
store
(
oid
,
serial
,
data
,
dest
,
t
)
...
@@ -464,7 +464,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -464,7 +464,7 @@ class Connection(ExportImport.ExportImport):
def
db
(
self
):
return
self
.
_db
def
db
(
self
):
return
self
.
_db
def
getVersion
(
self
):
return
self
.
_version
def
getVersion
(
self
):
return
self
.
_version
def
invalidate
(
self
,
oid
):
def
invalidate
(
self
,
oid
):
"""Invalidate a particular oid
"""Invalidate a particular oid
...
@@ -575,21 +575,21 @@ class Connection(ExportImport.ExportImport):
...
@@ -575,21 +575,21 @@ class Connection(ExportImport.ExportImport):
file
=
StringIO
(
p
)
file
=
StringIO
(
p
)
unpickler
=
Unpickler
(
file
)
unpickler
=
Unpickler
(
file
)
unpickler
.
persistent_load
=
self
.
_persistent_load
unpickler
.
persistent_load
=
self
.
_persistent_load
copy
=
unpickler
.
load
()
copy
=
unpickler
.
load
()
klass
,
args
=
copy
klass
,
args
=
copy
if
klass
is
not
ExtensionKlass
:
if
klass
is
not
ExtensionKlass
:
LOG
(
'ZODB'
,
ERROR
,
LOG
(
'ZODB'
,
ERROR
,
"Unexpected klass when setting class state on %s"
"Unexpected klass when setting class state on %s"
%
getattr
(
object
,
'__name__'
,
'(?)'
))
%
getattr
(
object
,
'__name__'
,
'(?)'
))
return
return
copy
=
apply
(
klass
,
args
)
copy
=
apply
(
klass
,
args
)
object
.
__dict__
.
clear
()
object
.
__dict__
.
clear
()
object
.
__dict__
.
update
(
copy
.
__dict__
)
object
.
__dict__
.
update
(
copy
.
__dict__
)
object
.
_p_oid
=
oid
object
.
_p_oid
=
oid
object
.
_p_jar
=
self
object
.
_p_jar
=
self
object
.
_p_changed
=
0
object
.
_p_changed
=
0
...
@@ -647,7 +647,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -647,7 +647,7 @@ class Connection(ExportImport.ExportImport):
# update the _p_changed flag, because the subtransaction
# update the _p_changed flag, because the subtransaction
# tpc_vote() calls already did this. The change=1 argument
# tpc_vote() calls already did this. The change=1 argument
# exists to allow commit_sub() to avoid setting the flag
# exists to allow commit_sub() to avoid setting the flag
# again.
# again.
if
not
store_return
:
if
not
store_return
:
return
return
if
isinstance
(
store_return
,
StringType
):
if
isinstance
(
store_return
,
StringType
):
...
@@ -712,7 +712,7 @@ class Connection(ExportImport.ExportImport):
...
@@ -712,7 +712,7 @@ class Connection(ExportImport.ExportImport):
def
getDebugInfo
(
self
):
def
getDebugInfo
(
self
):
return
self
.
_debug_info
return
self
.
_debug_info
def
setDebugInfo
(
self
,
*
args
):
def
setDebugInfo
(
self
,
*
args
):
self
.
_debug_info
=
self
.
_debug_info
+
args
self
.
_debug_info
=
self
.
_debug_info
+
args
...
@@ -737,9 +737,8 @@ class Connection(ExportImport.ExportImport):
...
@@ -737,9 +737,8 @@ class Connection(ExportImport.ExportImport):
new
.
_p_changed
=
1
new
.
_p_changed
=
1
get_transaction
().
register
(
new
)
get_transaction
().
register
(
new
)
self
.
_cache
[
oid
]
=
new
self
.
_cache
[
oid
]
=
new
class
tConnection
(
Connection
):
class
tConnection
(
Connection
):
def
close
(
self
):
def
close
(
self
):
self
.
_breakcr
()
self
.
_breakcr
()
trunk/src/ZODB/DB.py
View file @
bc40c6a3
...
@@ -2,19 +2,19 @@
...
@@ -2,19 +2,19 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Database objects
"""Database objects
$Id: DB.py,v 1.4
2 2002/06/10 20:20:44 shane
Exp $"""
$Id: DB.py,v 1.4
3 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.4
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
3
$'
[
11
:
-
2
]
import
cPickle
,
cStringIO
,
sys
,
POSException
,
UndoLogCompatible
import
cPickle
,
cStringIO
,
sys
,
POSException
,
UndoLogCompatible
from
Connection
import
Connection
from
Connection
import
Connection
...
@@ -101,7 +101,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -101,7 +101,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
if
hasattr
(
storage
,
'undoInfo'
):
if
hasattr
(
storage
,
'undoInfo'
):
self
.
undoInfo
=
storage
.
undoInfo
self
.
undoInfo
=
storage
.
undoInfo
def
_cacheMean
(
self
,
attr
):
def
_cacheMean
(
self
,
attr
):
# XXX this method doesn't work
# XXX this method doesn't work
...
@@ -120,7 +120,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -120,7 +120,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
_silly
=
(
'__doc__'
,),
_globals
=
{}):
_silly
=
(
'__doc__'
,),
_globals
=
{}):
return
getattr
(
__import__
(
location
,
_globals
,
_globals
,
_silly
),
return
getattr
(
__import__
(
location
,
_globals
,
_globals
,
_silly
),
name
)
name
)
def
_closeConnection
(
self
,
connection
):
def
_closeConnection
(
self
,
connection
):
"""Return a connection to the pool"""
"""Return a connection to the pool"""
self
.
_a
()
self
.
_a
()
...
@@ -136,7 +136,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -136,7 +136,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
# Pool now usable again, unlock it.
# Pool now usable again, unlock it.
pool_lock
.
release
()
pool_lock
.
release
()
finally
:
self
.
_r
()
finally
:
self
.
_r
()
def
_connectionMap
(
self
,
f
):
def
_connectionMap
(
self
,
f
):
self
.
_a
()
self
.
_a
()
try
:
try
:
...
@@ -171,7 +171,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -171,7 +171,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
detail
[
c
]
=
detail
[
c
]
+
1
detail
[
c
]
=
detail
[
c
]
+
1
else
:
else
:
detail
[
c
]
=
1
detail
[
c
]
=
1
self
.
_connectionMap
(
f
)
self
.
_connectionMap
(
f
)
detail
=
detail
.
items
()
detail
=
detail
.
items
()
detail
.
sort
()
detail
.
sort
()
...
@@ -194,7 +194,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -194,7 +194,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
module
=
getattr
(
ob
.
__class__
,
'__module__'
,
''
)
module
=
getattr
(
ob
.
__class__
,
'__module__'
,
''
)
module
=
module
and
'%s.'
%
module
or
''
module
=
module
and
'%s.'
%
module
or
''
detail
.
append
({
detail
.
append
({
'conn_no'
:
cn
,
'conn_no'
:
cn
,
'oid'
:
oid
,
'oid'
:
oid
,
...
@@ -252,10 +252,10 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -252,10 +252,10 @@ class DB(UndoLogCompatible.UndoLogCompatible):
def
exportFile
(
self
,
oid
,
file
=
None
):
def
exportFile
(
self
,
oid
,
file
=
None
):
raise
'Not yet implemented'
raise
'Not yet implemented'
def
getCacheDeactivateAfter
(
self
):
def
getCacheDeactivateAfter
(
self
):
return
self
.
_cache_deactivate_after
return
self
.
_cache_deactivate_after
def
getCacheSize
(
self
):
def
getCacheSize
(
self
):
return
self
.
_cache_size
return
self
.
_cache_size
...
@@ -267,7 +267,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -267,7 +267,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
def
getVersionCacheDeactivateAfter
(
self
):
def
getVersionCacheDeactivateAfter
(
self
):
return
self
.
_version_cache_deactivate_after
return
self
.
_version_cache_deactivate_after
def
getVersionCacheSize
(
self
):
def
getVersionCacheSize
(
self
):
return
self
.
_version_cache_size
return
self
.
_version_cache_size
...
@@ -336,7 +336,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -336,7 +336,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
def
objectCount
(
self
):
def
objectCount
(
self
):
return
len
(
self
.
_storage
)
return
len
(
self
.
_storage
)
def
open
(
self
,
version
=
''
,
transaction
=
None
,
temporary
=
0
,
force
=
None
,
def
open
(
self
,
version
=
''
,
transaction
=
None
,
temporary
=
0
,
force
=
None
,
waitflag
=
1
):
waitflag
=
1
):
"""Return a object space (AKA connection) to work in
"""Return a object space (AKA connection) to work in
...
@@ -354,7 +354,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -354,7 +354,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
"""
"""
if
type
(
version
)
is
not
StringType
:
if
type
(
version
)
is
not
StringType
:
raise
POSException
.
Unimplemented
,
'temporary versions'
raise
POSException
.
Unimplemented
,
'temporary versions'
self
.
_a
()
self
.
_a
()
try
:
try
:
...
@@ -366,7 +366,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -366,7 +366,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
else
:
else
:
transaction
.
_connections
=
connections
=
{}
transaction
.
_connections
=
connections
=
{}
transaction
=
transaction
.
_connections
transaction
=
transaction
.
_connections
if
temporary
:
if
temporary
:
# This is a temporary connection.
# This is a temporary connection.
...
@@ -407,7 +407,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -407,7 +407,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
# the last connection from the pool and just after adding
# the last connection from the pool and just after adding
# a connection to an empty pool.
# a connection to an empty pool.
if
pools
.
has_key
(
version
):
if
pools
.
has_key
(
version
):
pool
,
allocated
,
pool_lock
=
pools
[
version
]
pool
,
allocated
,
pool_lock
=
pools
[
version
]
else
:
else
:
...
@@ -432,7 +432,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -432,7 +432,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
cache_size
=
self
.
_cache_size
)
cache_size
=
self
.
_cache_size
)
allocated
.
append
(
c
)
allocated
.
append
(
c
)
pool
.
append
(
c
)
pool
.
append
(
c
)
if
c
is
None
:
if
c
is
None
:
if
waitflag
:
if
waitflag
:
self
.
_r
()
self
.
_r
()
...
@@ -482,17 +482,17 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -482,17 +482,17 @@ class DB(UndoLogCompatible.UndoLogCompatible):
if
len
(
d
)
==
1
:
d
=
d
[
0
]
if
len
(
d
)
==
1
:
d
=
d
[
0
]
else
:
d
=
''
else
:
d
=
''
d
=
"%s (%s)"
%
(
d
,
len
(
c
.
_cache
))
d
=
"%s (%s)"
%
(
d
,
len
(
c
.
_cache
))
r
.
append
({
r
.
append
({
'opened'
:
o
and
(
"%s (%.2fs)"
%
(
ctime
(
o
),
t
-
o
)),
'opened'
:
o
and
(
"%s (%.2fs)"
%
(
ctime
(
o
),
t
-
o
)),
'info'
:
d
,
'info'
:
d
,
'version'
:
version
,
'version'
:
version
,
})
})
return
r
return
r
def
getActivityMonitor
(
self
):
def
getActivityMonitor
(
self
):
return
self
.
_activity_monitor
return
self
.
_activity_monitor
def
pack
(
self
,
t
=
None
,
days
=
0
):
def
pack
(
self
,
t
=
None
,
days
=
0
):
if
t
is
None
:
t
=
time
()
if
t
is
None
:
t
=
time
()
t
=
t
-
(
days
*
86400
)
t
=
t
-
(
days
*
86400
)
...
@@ -500,7 +500,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -500,7 +500,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
except
:
except
:
LOG
(
"ZODB"
,
ERROR
,
"packing"
,
error
=
sys
.
exc_info
())
LOG
(
"ZODB"
,
ERROR
,
"packing"
,
error
=
sys
.
exc_info
())
raise
raise
def
setCacheDeactivateAfter
(
self
,
v
):
def
setCacheDeactivateAfter
(
self
,
v
):
self
.
_cache_deactivate_after
=
v
self
.
_cache_deactivate_after
=
v
d
=
self
.
_pools
[
0
]
d
=
self
.
_pools
[
0
]
...
@@ -539,7 +539,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
...
@@ -539,7 +539,7 @@ class DB(UndoLogCompatible.UndoLogCompatible):
if
ver
:
if
ver
:
for
c
in
self
.
_pools
[
0
][
ver
][
1
]:
for
c
in
self
.
_pools
[
0
][
ver
][
1
]:
c
.
_cache
.
cache_size
=
v
c
.
_cache
.
cache_size
=
v
def
setVersionPoolSize
(
self
,
v
):
self
.
_version_pool_size
=
v
def
setVersionPoolSize
(
self
,
v
):
self
.
_version_pool_size
=
v
def
cacheStatistics
(
self
):
return
()
# :(
def
cacheStatistics
(
self
):
return
()
# :(
...
@@ -590,7 +590,7 @@ class CommitVersion:
...
@@ -590,7 +590,7 @@ class CommitVersion:
# the code above just invalidated the dest version.
# the code above just invalidated the dest version.
# now we need to invalidate the source!
# now we need to invalidate the source!
for
oid
in
oids
:
db
.
invalidate
(
oid
,
version
=
self
.
_version
)
for
oid
in
oids
:
db
.
invalidate
(
oid
,
version
=
self
.
_version
)
class
AbortVersion
(
CommitVersion
):
class
AbortVersion
(
CommitVersion
):
"""An object that will see to version abortion
"""An object that will see to version abortion
...
@@ -610,7 +610,7 @@ class TransactionalUndo(CommitVersion):
...
@@ -610,7 +610,7 @@ class TransactionalUndo(CommitVersion):
in cooperation with a transaction manager.
in cooperation with a transaction manager.
"""
"""
# I'm lazy. I'm reusing __init__ and abort and reusing the
# I'm lazy. I'm reusing __init__ and abort and reusing the
# version attr for the transavtion id. There's such a strong
# version attr for the transavtion id. There's such a strong
# similarity of rythm, that I think it's justified.
# similarity of rythm, that I think it's justified.
...
...
trunk/src/ZODB/DemoStorage.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Demo ZODB storage
"""Demo ZODB storage
...
@@ -45,7 +45,7 @@ There are three main data structures:
...
@@ -45,7 +45,7 @@ There are three main data structures:
A record is a tuple:
A record is a tuple:
oid, serial, pre, vdata, p,
oid, serial, pre, vdata, p,
where:
where:
...
@@ -79,7 +79,7 @@ method::
...
@@ -79,7 +79,7 @@ method::
and call it to monitor the storage.
and call it to monitor the storage.
"""
"""
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
import
base64
,
time
,
string
import
base64
,
time
,
string
from
ZODB
import
POSException
,
BaseStorage
,
utils
from
ZODB
import
POSException
,
BaseStorage
,
utils
...
@@ -109,7 +109,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -109,7 +109,7 @@ class DemoStorage(BaseStorage.BaseStorage):
def
__len__
(
self
):
def
__len__
(
self
):
base
=
self
.
_base
base
=
self
.
_base
return
(
base
and
len
(
base
)
or
0
)
+
len
(
self
.
_index
)
return
(
base
and
len
(
base
)
or
0
)
+
len
(
self
.
_index
)
def
getSize
(
self
):
def
getSize
(
self
):
s
=
100
s
=
100
for
tid
,
(
p
,
u
,
d
,
e
,
t
)
in
self
.
_data
.
items
():
for
tid
,
(
p
,
u
,
d
,
e
,
t
)
in
self
.
_data
.
items
():
...
@@ -131,12 +131,12 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -131,12 +131,12 @@ class DemoStorage(BaseStorage.BaseStorage):
raise
POSException
.
StorageTransactionError
(
self
,
transaction
)
raise
POSException
.
StorageTransactionError
(
self
,
transaction
)
if
not
src
:
if
not
src
:
raise
POSException
.
VersionCommitError
(
"Invalid version"
)
raise
POSException
.
VersionCommitError
(
"Invalid version"
)
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
v
=
self
.
_vindex
.
get
(
src
,
None
)
v
=
self
.
_vindex
.
get
(
src
,
None
)
if
not
v
:
return
if
not
v
:
return
tindex
=
self
.
_tindex
tindex
=
self
.
_tindex
oids
=
[]
oids
=
[]
for
r
in
v
.
values
():
for
r
in
v
.
values
():
...
@@ -147,16 +147,16 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -147,16 +147,16 @@ class DemoStorage(BaseStorage.BaseStorage):
tindex
.
append
([
oid
,
serial
,
r
,
None
,
p
])
tindex
.
append
([
oid
,
serial
,
r
,
None
,
p
])
else
:
else
:
# effectively, delete the thing
# effectively, delete the thing
tindex
.
append
([
oid
,
None
,
r
,
None
,
None
])
tindex
.
append
([
oid
,
None
,
r
,
None
,
None
])
return
oids
return
oids
finally
:
self
.
_lock_release
()
finally
:
self
.
_lock_release
()
def
commitVersion
(
self
,
src
,
dest
,
transaction
):
def
commitVersion
(
self
,
src
,
dest
,
transaction
):
if
transaction
is
not
self
.
_transaction
:
if
transaction
is
not
self
.
_transaction
:
raise
POSException
.
StorageTransactionError
(
self
,
transaction
)
raise
POSException
.
StorageTransactionError
(
self
,
transaction
)
if
not
src
:
if
not
src
:
raise
POSException
.
VersionCommitError
(
"Invalid source version"
)
raise
POSException
.
VersionCommitError
(
"Invalid source version"
)
if
src
==
dest
:
if
src
==
dest
:
...
@@ -167,7 +167,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -167,7 +167,7 @@ class DemoStorage(BaseStorage.BaseStorage):
try
:
try
:
v
=
self
.
_vindex
.
get
(
src
,
None
)
v
=
self
.
_vindex
.
get
(
src
,
None
)
if
v
is
None
:
return
if
v
is
None
:
return
tindex
=
self
.
_tindex
tindex
=
self
.
_tindex
oids
=
[]
oids
=
[]
for
r
in
v
.
values
():
for
r
in
v
.
values
():
...
@@ -179,7 +179,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -179,7 +179,7 @@ class DemoStorage(BaseStorage.BaseStorage):
else
:
else
:
new_vdata
=
None
new_vdata
=
None
tindex
.
append
([
oid
,
serial
,
r
,
new_vdata
,
p
])
tindex
.
append
([
oid
,
serial
,
r
,
new_vdata
,
p
])
return
oids
return
oids
...
@@ -205,10 +205,10 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -205,10 +205,10 @@ class DemoStorage(BaseStorage.BaseStorage):
if
p
is
None
:
if
p
is
None
:
raise
KeyError
,
oid
raise
KeyError
,
oid
return
p
,
serial
return
p
,
serial
finally
:
self
.
_lock_release
()
finally
:
self
.
_lock_release
()
def
modifiedInVersion
(
self
,
oid
):
def
modifiedInVersion
(
self
,
oid
):
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
...
@@ -232,22 +232,22 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -232,22 +232,22 @@ class DemoStorage(BaseStorage.BaseStorage):
except
:
pass
except
:
pass
else
:
else
:
old
=
oid
,
oserial
,
None
,
None
,
p
old
=
oid
,
oserial
,
None
,
None
,
p
nv
=
None
nv
=
None
if
old
:
if
old
:
oid
,
oserial
,
pre
,
vdata
,
p
=
old
oid
,
oserial
,
pre
,
vdata
,
p
=
old
if
vdata
:
if
vdata
:
if
vdata
[
0
]
!=
version
:
if
vdata
[
0
]
!=
version
:
raise
POSException
.
VersionLockError
,
oid
raise
POSException
.
VersionLockError
,
oid
nv
=
vdata
[
1
]
nv
=
vdata
[
1
]
else
:
else
:
nv
=
old
nv
=
old
if
serial
!=
oserial
:
if
serial
!=
oserial
:
raise
POSException
.
ConflictError
(
serials
=
(
oserial
,
serial
))
raise
POSException
.
ConflictError
(
serials
=
(
oserial
,
serial
))
serial
=
self
.
_serial
serial
=
self
.
_serial
r
=
[
oid
,
serial
,
old
,
version
and
(
version
,
nv
)
or
None
,
data
]
r
=
[
oid
,
serial
,
old
,
version
and
(
version
,
nv
)
or
None
,
data
]
self
.
_tindex
.
append
(
r
)
self
.
_tindex
.
append
(
r
)
...
@@ -274,7 +274,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -274,7 +274,7 @@ class DemoStorage(BaseStorage.BaseStorage):
def
_begin
(
self
,
tid
,
u
,
d
,
e
):
def
_begin
(
self
,
tid
,
u
,
d
,
e
):
self
.
_tsize
=
self
.
_size
+
120
+
len
(
u
)
+
len
(
d
)
+
len
(
e
)
self
.
_tsize
=
self
.
_size
+
120
+
len
(
u
)
+
len
(
d
)
+
len
(
e
)
def
_finish
(
self
,
tid
,
user
,
desc
,
ext
):
def
_finish
(
self
,
tid
,
user
,
desc
,
ext
):
index
=
self
.
_index
index
=
self
.
_index
...
@@ -293,9 +293,9 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -293,9 +293,9 @@ class DemoStorage(BaseStorage.BaseStorage):
v
=
vindex
[
oldvdata
[
0
]]
v
=
vindex
[
oldvdata
[
0
]]
del
v
[
oid
]
del
v
[
oid
]
if
not
v
:
del
vindex
[
oldvdata
[
0
]]
if
not
v
:
del
vindex
[
oldvdata
[
0
]]
index
[
oid
]
=
r
index
[
oid
]
=
r
if
vdata
:
if
vdata
:
version
=
vdata
[
0
]
version
=
vdata
[
0
]
v
=
vindex
.
get
(
version
,
None
)
v
=
vindex
.
get
(
version
,
None
)
...
@@ -321,7 +321,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -321,7 +321,7 @@ class DemoStorage(BaseStorage.BaseStorage):
for
r
in
t
:
for
r
in
t
:
oid
,
serial
,
pre
,
vdata
,
p
=
r
oid
,
serial
,
pre
,
vdata
,
p
=
r
if
pre
:
if
pre
:
index
[
oid
]
=
pre
index
[
oid
]
=
pre
oids
.
append
(
oid
)
oids
.
append
(
oid
)
...
@@ -338,7 +338,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -338,7 +338,7 @@ class DemoStorage(BaseStorage.BaseStorage):
v
=
vindex
.
get
(
version
,
None
)
v
=
vindex
.
get
(
version
,
None
)
if
v
is
None
:
v
=
vindex
[
version
]
=
{}
if
v
is
None
:
v
=
vindex
[
version
]
=
{}
v
[
oid
]
=
pre
v
[
oid
]
=
pre
else
:
else
:
del
index
[
oid
]
del
index
[
oid
]
if
vdata
:
if
vdata
:
...
@@ -413,7 +413,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -413,7 +413,7 @@ class DemoStorage(BaseStorage.BaseStorage):
v
=
vindex
[
oldvdata
[
0
]]
v
=
vindex
[
oldvdata
[
0
]]
del
v
[
oid
]
del
v
[
oid
]
if
not
v
:
del
vindex
[
oldvdata
[
0
]]
if
not
v
:
del
vindex
[
oldvdata
[
0
]]
index
[
oid
]
=
r
index
[
oid
]
=
r
if
vdata
:
if
vdata
:
...
@@ -428,16 +428,16 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -428,16 +428,16 @@ class DemoStorage(BaseStorage.BaseStorage):
# Packing is hard, at least when undo is supported.
# Packing is hard, at least when undo is supported.
# Even for a simple storage like this one, packing
# Even for a simple storage like this one, packing
# is pretty complex.
# is pretty complex.
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
stop
=
`apply(TimeStamp, time.gmtime(t)[:5]+(t%60,))`
stop
=
`apply(TimeStamp, time.gmtime(t)[:5]+(t%60,))`
_data
=
self
.
_data
_data
=
self
.
_data
# Build indexes up to the pack time:
# Build indexes up to the pack time:
index
,
vindex
=
self
.
_build_indexes
(
stop
)
index
,
vindex
=
self
.
_build_indexes
(
stop
)
# Now build an index of *only* those objects reachable
# Now build an index of *only* those objects reachable
# from the root.
# from the root.
rootl
=
[
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
]
rootl
=
[
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
]
...
@@ -447,7 +447,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -447,7 +447,7 @@ class DemoStorage(BaseStorage.BaseStorage):
while
rootl
:
while
rootl
:
oid
=
pop
()
oid
=
pop
()
if
referenced
(
oid
):
continue
if
referenced
(
oid
):
continue
# Scan non-version pickle for references
# Scan non-version pickle for references
r
=
index
.
get
(
oid
,
None
)
r
=
index
.
get
(
oid
,
None
)
if
r
is
None
:
if
r
is
None
:
...
@@ -463,7 +463,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -463,7 +463,7 @@ class DemoStorage(BaseStorage.BaseStorage):
if
nv
:
if
nv
:
oid
,
serial
,
pre
,
vdata
,
p
=
nv
oid
,
serial
,
pre
,
vdata
,
p
=
nv
referencesf
(
p
,
rootl
)
referencesf
(
p
,
rootl
)
# Now we're ready to do the actual packing.
# Now we're ready to do the actual packing.
# We'll simply edit the transaction data in place.
# We'll simply edit the transaction data in place.
# We'll defer deleting transactions till the end
# We'll defer deleting transactions till the end
...
@@ -484,7 +484,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -484,7 +484,7 @@ class DemoStorage(BaseStorage.BaseStorage):
if
vdata
:
if
vdata
:
# Version record are current *only* if they
# Version record are current *only* if they
# are indexed
# are indexed
continue
continue
else
:
else
:
# OK, this isn't a version record, so it may be the
# OK, this isn't a version record, so it may be the
# non-version record for the indexed record.
# non-version record for the indexed record.
...
@@ -500,16 +500,16 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -500,16 +500,16 @@ class DemoStorage(BaseStorage.BaseStorage):
# record for it.
# record for it.
continue
continue
o
.
append
(
r
)
o
.
append
(
r
)
if
o
:
if
o
:
if
len
(
o
)
!=
len
(
t
):
if
len
(
o
)
!=
len
(
t
):
_data
[
tid
]
=
1
,
u
,
d
,
e
,
tuple
(
o
)
# Reset data
_data
[
tid
]
=
1
,
u
,
d
,
e
,
tuple
(
o
)
# Reset data
else
:
else
:
deleted
.
append
(
tid
)
deleted
.
append
(
tid
)
# Now delete empty transactions
# Now delete empty transactions
for
tid
in
deleted
:
del
_data
[
tid
]
for
tid
in
deleted
:
del
_data
[
tid
]
# Now reset previous pointers for "current" records:
# Now reset previous pointers for "current" records:
for
r
in
pindex
.
values
():
for
r
in
pindex
.
values
():
r
[
2
]
=
None
# Previous record
r
[
2
]
=
None
# Previous record
...
@@ -517,7 +517,7 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -517,7 +517,7 @@ class DemoStorage(BaseStorage.BaseStorage):
r
[
3
][
1
][
2
]
=
None
r
[
3
][
1
][
2
]
=
None
pindex
=
None
pindex
=
None
# Finally, rebuild indexes from transaction data:
# Finally, rebuild indexes from transaction data:
self
.
_index
,
self
.
_vindex
=
self
.
_build_indexes
()
self
.
_index
,
self
.
_vindex
=
self
.
_build_indexes
()
...
@@ -559,6 +559,6 @@ class DemoStorage(BaseStorage.BaseStorage):
...
@@ -559,6 +559,6 @@ class DemoStorage(BaseStorage.BaseStorage):
for
oid
,
r
in
vitems
:
for
oid
,
r
in
vitems
:
if
r
:
r
=
id
(
r
)
if
r
:
r
=
id
(
r
)
o
.
append
(
' %s: %s'
%
(
utils
.
u64
(
oid
),
r
))
o
.
append
(
' %s: %s'
%
(
utils
.
u64
(
oid
),
r
))
return
string
.
join
(
o
,
'
\
n
'
)
return
string
.
join
(
o
,
'
\
n
'
)
trunk/src/ZODB/ExportImport.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Support for database export and import.
"""Support for database export and import.
...
@@ -60,7 +60,7 @@ class ExportImport:
...
@@ -60,7 +60,7 @@ class ExportImport:
file
=
open
(
file
,
'rb'
)
file
=
open
(
file
,
'rb'
)
else
:
else
:
try
:
file_name
=
file
.
name
try
:
file_name
=
file
.
name
except
:
file_name
=
'(unknown)'
except
:
file_name
=
'(unknown)'
read
=
file
.
read
read
=
file
.
read
magic
=
read
(
4
)
magic
=
read
(
4
)
...
@@ -100,7 +100,7 @@ class ExportImport:
...
@@ -100,7 +100,7 @@ class ExportImport:
atoi
=
string
.
atoi
,
TupleType
=
type
(()),
atoi
=
string
.
atoi
,
TupleType
=
type
(()),
oids
=
oids
,
wrote_oid
=
oids
.
has_key
,
oids
=
oids
,
wrote_oid
=
oids
.
has_key
,
new_oid
=
storage
.
new_oid
):
new_oid
=
storage
.
new_oid
):
"Remap a persistent id to a new ID and create a ghost for it."
"Remap a persistent id to a new ID and create a ghost for it."
if
type
(
ooid
)
is
TupleType
:
ooid
,
klass
=
ooid
if
type
(
ooid
)
is
TupleType
:
ooid
,
klass
=
ooid
...
@@ -168,4 +168,3 @@ class Ghost: pass
...
@@ -168,4 +168,3 @@ class Ghost: pass
def
persistent_id
(
object
,
Ghost
=
Ghost
):
def
persistent_id
(
object
,
Ghost
=
Ghost
):
if
getattr
(
object
,
'__class__'
,
None
)
is
Ghost
:
if
getattr
(
object
,
'__class__'
,
None
)
is
Ghost
:
return
object
.
oid
return
object
.
oid
trunk/src/ZODB/FileStorage.py
View file @
bc40c6a3
This diff is collapsed.
Click to expand it.
trunk/src/ZODB/MappingStorage.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Very Simple Mapping ZODB storage
"""Very Simple Mapping ZODB storage
...
@@ -53,7 +53,7 @@ There are three main data structures:
...
@@ -53,7 +53,7 @@ There are three main data structures:
A record is a tuple:
A record is a tuple:
oid, serial, pre, vdata, p,
oid, serial, pre, vdata, p,
where:
where:
...
@@ -87,7 +87,7 @@ method::
...
@@ -87,7 +87,7 @@ method::
and call it to minotor the storage.
and call it to minotor the storage.
"""
"""
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
import
POSException
,
BaseStorage
,
string
,
utils
import
POSException
,
BaseStorage
,
string
,
utils
from
TimeStamp
import
TimeStamp
from
TimeStamp
import
TimeStamp
...
@@ -108,14 +108,14 @@ class MappingStorage(BaseStorage.BaseStorage):
...
@@ -108,14 +108,14 @@ class MappingStorage(BaseStorage.BaseStorage):
def
__len__
(
self
):
def
__len__
(
self
):
return
len
(
self
.
_index
)
return
len
(
self
.
_index
)
def
getSize
(
self
):
def
getSize
(
self
):
s
=
32
s
=
32
index
=
self
.
_index
index
=
self
.
_index
for
oid
in
index
.
keys
():
for
oid
in
index
.
keys
():
p
=
index
[
oid
]
p
=
index
[
oid
]
s
=
s
+
56
+
len
(
p
)
s
=
s
+
56
+
len
(
p
)
return
s
return
s
def
load
(
self
,
oid
,
version
):
def
load
(
self
,
oid
,
version
):
...
@@ -139,7 +139,7 @@ class MappingStorage(BaseStorage.BaseStorage):
...
@@ -139,7 +139,7 @@ class MappingStorage(BaseStorage.BaseStorage):
oserial
=
old
[:
8
]
oserial
=
old
[:
8
]
if
serial
!=
oserial
:
if
serial
!=
oserial
:
raise
POSException
.
ConflictError
(
serials
=
(
oserial
,
serial
))
raise
POSException
.
ConflictError
(
serials
=
(
oserial
,
serial
))
serial
=
self
.
_serial
serial
=
self
.
_serial
self
.
_tindex
.
append
((
oid
,
serial
+
data
))
self
.
_tindex
.
append
((
oid
,
serial
+
data
))
finally
:
self
.
_lock_release
()
finally
:
self
.
_lock_release
()
...
@@ -155,9 +155,9 @@ class MappingStorage(BaseStorage.BaseStorage):
...
@@ -155,9 +155,9 @@ class MappingStorage(BaseStorage.BaseStorage):
for
oid
,
p
in
self
.
_tindex
:
index
[
oid
]
=
p
for
oid
,
p
in
self
.
_tindex
:
index
[
oid
]
=
p
def
pack
(
self
,
t
,
referencesf
):
def
pack
(
self
,
t
,
referencesf
):
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
# Build an index of *only* those objects reachable
# Build an index of *only* those objects reachable
# from the root.
# from the root.
index
=
self
.
_index
index
=
self
.
_index
...
@@ -168,7 +168,7 @@ class MappingStorage(BaseStorage.BaseStorage):
...
@@ -168,7 +168,7 @@ class MappingStorage(BaseStorage.BaseStorage):
while
rootl
:
while
rootl
:
oid
=
pop
()
oid
=
pop
()
if
referenced
(
oid
):
continue
if
referenced
(
oid
):
continue
# Scan non-version pickle for references
# Scan non-version pickle for references
r
=
index
[
oid
]
r
=
index
[
oid
]
pindex
[
oid
]
=
r
pindex
[
oid
]
=
r
...
@@ -178,7 +178,7 @@ class MappingStorage(BaseStorage.BaseStorage):
...
@@ -178,7 +178,7 @@ class MappingStorage(BaseStorage.BaseStorage):
# Now delete any unreferenced entries:
# Now delete any unreferenced entries:
for
oid
in
index
.
keys
():
for
oid
in
index
.
keys
():
if
not
referenced
(
oid
):
del
index
[
oid
]
if
not
referenced
(
oid
):
del
index
[
oid
]
finally
:
self
.
_lock_release
()
finally
:
self
.
_lock_release
()
def
_splat
(
self
):
def
_splat
(
self
):
...
@@ -193,5 +193,5 @@ class MappingStorage(BaseStorage.BaseStorage):
...
@@ -193,5 +193,5 @@ class MappingStorage(BaseStorage.BaseStorage):
r
=
index
[
oid
]
r
=
index
[
oid
]
o
.
append
(
' %s: %s, %s'
%
o
.
append
(
' %s: %s, %s'
%
(
utils
.
u64
(
oid
),
TimeStamp
(
r
[:
8
]),
`r[8:]`
))
(
utils
.
u64
(
oid
),
TimeStamp
(
r
[:
8
]),
`r[8:]`
))
return
string
.
join
(
o
,
'
\
n
'
)
return
string
.
join
(
o
,
'
\
n
'
)
trunk/src/ZODB/Mount.py
View file @
bc40c6a3
...
@@ -2,19 +2,19 @@
...
@@ -2,19 +2,19 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Mounted database support
"""Mounted database support
$Id: Mount.py,v 1.1
5 2002/05/23 20:53:22 shane
Exp $"""
$Id: Mount.py,v 1.1
6 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.1
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
6
$'
[
11
:
-
2
]
import
thread
,
Persistence
,
Acquisition
import
thread
,
Persistence
,
Acquisition
import
ExtensionClass
,
string
,
time
,
sys
import
ExtensionClass
,
string
,
time
,
sys
...
@@ -188,7 +188,7 @@ class MountPoint(Persistence.Persistent, Acquisition.Implicit):
...
@@ -188,7 +188,7 @@ class MountPoint(Persistence.Persistent, Acquisition.Implicit):
data
=
t
[
0
]
data
=
t
[
0
]
return
data
.
__of__
(
parent
)
return
data
.
__of__
(
parent
)
def
__of__
(
self
,
parent
):
def
__of__
(
self
,
parent
):
# Accesses the database, returning an acquisition
# Accesses the database, returning an acquisition
# wrapper around the connected object rather than around self.
# wrapper around the connected object rather than around self.
...
@@ -277,7 +277,7 @@ class MountedConnectionCloser:
...
@@ -277,7 +277,7 @@ class MountedConnectionCloser:
try
:
del
conn
.
_mount_parent_jar
try
:
del
conn
.
_mount_parent_jar
except
:
pass
except
:
pass
conn
.
close
()
conn
.
close
()
if
close_db
:
if
close_db
:
# Stop using this database. Close it if no other
# Stop using this database. Close it if no other
# MountPoint is using it.
# MountPoint is using it.
...
...
trunk/src/ZODB/POSException.py
View file @
bc40c6a3
...
@@ -2,19 +2,19 @@
...
@@ -2,19 +2,19 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""BoboPOS-defined exceptions
"""BoboPOS-defined exceptions
$Id: POSException.py,v 1.1
1 2002/02/11 23:40:42 gvanrossum
Exp $"""
$Id: POSException.py,v 1.1
2 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.1
1
$'
.
split
()[
-
2
:][
0
]
__version__
=
'$Revision: 1.1
2
$'
.
split
()[
-
2
:][
0
]
from
string
import
join
from
string
import
join
from
types
import
StringType
,
DictType
from
types
import
StringType
,
DictType
...
@@ -193,7 +193,7 @@ class Unimplemented(POSError):
...
@@ -193,7 +193,7 @@ class Unimplemented(POSError):
class
Unsupported
(
POSError
):
class
Unsupported
(
POSError
):
"""An feature that is unsupported bt the storage was used.
"""An feature that is unsupported bt the storage was used.
"""
"""
class
InvalidObjectReference
(
POSError
):
class
InvalidObjectReference
(
POSError
):
"""An object contains an invalid reference to another object.
"""An object contains an invalid reference to another object.
...
...
trunk/src/ZODB/PersistentList.py
View file @
bc40c6a3
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python implementation of persistent list.
"""Python implementation of persistent list.
$Id: PersistentList.py,v 1.
2 2002/02/11 23:49:07 gvanrossum
Exp $"""
$Id: PersistentList.py,v 1.
3 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
from
UserList
import
UserList
from
UserList
import
UserList
...
@@ -51,7 +51,7 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -51,7 +51,7 @@ class PersistentList(UserList, Persistence.Persistent):
def
__delslice__
(
self
,
i
,
j
):
def
__delslice__
(
self
,
i
,
j
):
self
.
__super_delslice
(
i
,
j
)
self
.
__super_delslice
(
i
,
j
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
__iadd__
(
self
,
other
):
def
__iadd__
(
self
,
other
):
self
.
__super_iadd
(
other
)
self
.
__super_iadd
(
other
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
@@ -63,7 +63,7 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -63,7 +63,7 @@ class PersistentList(UserList, Persistence.Persistent):
def
append
(
self
,
item
):
def
append
(
self
,
item
):
self
.
__super_append
(
item
)
self
.
__super_append
(
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
insert
(
self
,
i
,
item
):
def
insert
(
self
,
i
,
item
):
self
.
__super_insert
(
i
,
item
)
self
.
__super_insert
(
i
,
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
@@ -76,11 +76,11 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -76,11 +76,11 @@ class PersistentList(UserList, Persistence.Persistent):
def
remove
(
self
,
item
):
def
remove
(
self
,
item
):
self
.
__super_remove
(
item
)
self
.
__super_remove
(
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
reverse
(
self
):
def
reverse
(
self
):
self
.
__super_reverse
()
self
.
__super_reverse
()
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
sort
(
self
,
*
args
):
def
sort
(
self
,
*
args
):
self
.
__super_sort
(
*
args
)
self
.
__super_sort
(
*
args
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
...
trunk/src/ZODB/PersistentMapping.py
View file @
bc40c6a3
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python implementation of persistent base types
"""Python implementation of persistent base types
$Id: PersistentMapping.py,v 1.
19 2002/02/12 22:33:08 gvanrossum
Exp $"""
$Id: PersistentMapping.py,v 1.
20 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.
19
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
20
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
from
UserDict
import
UserDict
from
UserDict
import
UserDict
...
@@ -82,7 +82,7 @@ class PersistentMapping(UserDict, Persistence.Persistent):
...
@@ -82,7 +82,7 @@ class PersistentMapping(UserDict, Persistence.Persistent):
# different versions of the code. Compatibility works in both
# different versions of the code. Compatibility works in both
# directions, because an application may want to share a database
# directions, because an application may want to share a database
# between applications using different versions of the code.
# between applications using different versions of the code.
# Effectively, the original rep is part of the "API." To provide
# Effectively, the original rep is part of the "API." To provide
# full compatibility, the getstate and setstate must read and
# full compatibility, the getstate and setstate must read and
# right objects using the old rep.
# right objects using the old rep.
...
...
trunk/src/ZODB/TmpStore.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
POSException
import
POSException
...
@@ -53,7 +53,7 @@ class TmpStore:
...
@@ -53,7 +53,7 @@ class TmpStore:
if
h
[:
8
]
!=
oid
:
if
h
[:
8
]
!=
oid
:
raise
POSException
.
StorageSystemError
,
'Bad temporary storage'
raise
POSException
.
StorageSystemError
,
'Bad temporary storage'
return
file
.
read
(
u64
(
h
[
16
:])),
h
[
8
:
16
]
return
file
.
read
(
u64
(
h
[
16
:])),
h
[
8
:
16
]
def
modifiedInVersion
(
self
,
oid
):
def
modifiedInVersion
(
self
,
oid
):
if
self
.
_index
.
has_key
(
oid
):
return
1
if
self
.
_index
.
has_key
(
oid
):
return
1
return
self
.
_db
.
_storage
.
modifiedInVersion
(
oid
)
return
self
.
_db
.
_storage
.
modifiedInVersion
(
oid
)
...
@@ -78,7 +78,7 @@ class TmpStore:
...
@@ -78,7 +78,7 @@ class TmpStore:
self
.
_tindex
.
append
((
oid
,
pos
))
self
.
_tindex
.
append
((
oid
,
pos
))
self
.
_pos
=
pos
+
l
+
24
self
.
_pos
=
pos
+
l
+
24
return
serial
return
serial
def
tpc_abort
(
self
,
transaction
):
def
tpc_abort
(
self
,
transaction
):
if
transaction
is
not
self
.
_transaction
:
return
if
transaction
is
not
self
.
_transaction
:
return
del
self
.
_tindex
[:]
del
self
.
_tindex
[:]
...
@@ -103,6 +103,6 @@ class TmpStore:
...
@@ -103,6 +103,6 @@ class TmpStore:
self
.
_tpos
=
self
.
_pos
self
.
_tpos
=
self
.
_pos
def
undoLog
(
self
,
first
,
last
,
filter
=
None
):
return
()
def
undoLog
(
self
,
first
,
last
,
filter
=
None
):
return
()
def
versionEmpty
(
self
,
version
):
def
versionEmpty
(
self
,
version
):
if
version
is
self
:
return
len
(
self
.
_index
)
if
version
is
self
:
return
len
(
self
.
_index
)
trunk/src/ZODB/Transaction.py
View file @
bc40c6a3
...
@@ -2,19 +2,19 @@
...
@@ -2,19 +2,19 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Transaction management
"""Transaction management
$Id: Transaction.py,v 1.3
6 2002/04/12 19:59:55 jeremy
Exp $"""
$Id: Transaction.py,v 1.3
7 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.3
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
7
$'
[
11
:
-
2
]
import
time
,
sys
,
struct
,
POSException
import
time
,
sys
,
struct
,
POSException
from
struct
import
pack
from
struct
import
pack
...
@@ -39,7 +39,7 @@ class Transaction:
...
@@ -39,7 +39,7 @@ class Transaction:
# commits and aborts to ensure that they are correctly committed
# commits and aborts to ensure that they are correctly committed
# or aborted in the "outside" transaction.
# or aborted in the "outside" transaction.
_non_st_objects
=
None
_non_st_objects
=
None
def
__init__
(
self
,
id
=
None
):
def
__init__
(
self
,
id
=
None
):
self
.
_id
=
id
self
.
_id
=
id
self
.
_objects
=
[]
self
.
_objects
=
[]
...
@@ -60,7 +60,7 @@ class Transaction:
...
@@ -60,7 +60,7 @@ class Transaction:
r
.
description
=
self
.
description
r
.
description
=
self
.
description
r
.
_extension
=
self
.
_extension
r
.
_extension
=
self
.
_extension
return
r
return
r
def
__str__
(
self
):
def
__str__
(
self
):
if
self
.
_id
is
None
:
if
self
.
_id
is
None
:
return
"Transaction user=%s"
%
`self.user`
return
"Transaction user=%s"
%
`self.user`
...
@@ -117,7 +117,7 @@ class Transaction:
...
@@ -117,7 +117,7 @@ class Transaction:
while
subjars
:
while
subjars
:
j
=
subjars
.
pop
()
j
=
subjars
.
pop
()
j
.
abort_sub
(
self
)
# This should never fail
j
.
abort_sub
(
self
)
# This should never fail
if
t
is
not
None
:
if
t
is
not
None
:
raise
t
,
v
,
tb
raise
t
,
v
,
tb
...
@@ -207,7 +207,7 @@ class Transaction:
...
@@ -207,7 +207,7 @@ class Transaction:
vote
(
self
)
# last chance to bail
vote
(
self
)
# last chance to bail
# Try to finish one jar, since we may be able to
# Try to finish one jar, since we may be able to
# recover if the first one fails.
# recover if the first one fails.
self
.
_finish_one
(
jarsv
)
self
.
_finish_one
(
jarsv
)
# Once a single jar has finished, it's a fatal (hosed)
# Once a single jar has finished, it's a fatal (hosed)
# error if another jar fails.
# error if another jar fails.
...
@@ -234,7 +234,7 @@ class Transaction:
...
@@ -234,7 +234,7 @@ class Transaction:
i
=
id
(
j
)
i
=
id
(
j
)
if
not
jars
.
has_key
(
i
):
if
not
jars
.
has_key
(
i
):
jars
[
i
]
=
j
jars
[
i
]
=
j
if
subtransaction
:
if
subtransaction
:
# If a jar does not support subtransactions,
# If a jar does not support subtransactions,
# we need to save it away to be committed in
# we need to save it away to be committed in
...
@@ -285,7 +285,7 @@ class Transaction:
...
@@ -285,7 +285,7 @@ class Transaction:
while
jarsv
:
while
jarsv
:
jarsv
[
-
1
].
tpc_finish
(
self
)
# This should never fail
jarsv
[
-
1
].
tpc_finish
(
self
)
# This should never fail
jarsv
.
pop
()
# It didn't, so it's taken care of.
jarsv
.
pop
()
# It didn't, so it's taken care of.
except
:
except
:
# Bug if it does, we need to yell FIRE!
# Bug if it does, we need to yell FIRE!
# Someone finished, so don't allow any more
# Someone finished, so don't allow any more
# work without at least a restart!
# work without at least a restart!
...
@@ -298,12 +298,12 @@ class Transaction:
...
@@ -298,12 +298,12 @@ class Transaction:
"until the site/storage is reset by a restart. "
,
"until the site/storage is reset by a restart. "
,
error
=
sys
.
exc_info
())
error
=
sys
.
exc_info
())
raise
raise
def
_commit_error
(
self
,
(
t
,
v
,
tb
),
def
_commit_error
(
self
,
(
t
,
v
,
tb
),
objects
,
ncommitted
,
jarsv
,
subjars
):
objects
,
ncommitted
,
jarsv
,
subjars
):
# handle an exception raised during commit
# handle an exception raised during commit
# takes sys.exc_info() as argument
# takes sys.exc_info() as argument
# First, we have to abort any uncommitted objects.
# First, we have to abort any uncommitted objects.
for
o
in
objects
[
ncommitted
:]:
for
o
in
objects
[
ncommitted
:]:
try
:
try
:
...
@@ -317,11 +317,11 @@ class Transaction:
...
@@ -317,11 +317,11 @@ class Transaction:
for
j
in
jarsv
:
for
j
in
jarsv
:
try
:
try
:
j
.
tpc_abort
(
self
)
# This should never fail
j
.
tpc_abort
(
self
)
# This should never fail
except
:
except
:
LOG
(
'ZODB'
,
ERROR
,
LOG
(
'ZODB'
,
ERROR
,
"A storage error occured during object abort. This "
"A storage error occured during object abort. This "
"shouldn't happen. "
,
error
=
sys
.
exc_info
())
"shouldn't happen. "
,
error
=
sys
.
exc_info
())
# Ugh, we need to abort work done in sub-transactions.
# Ugh, we need to abort work done in sub-transactions.
while
subjars
:
while
subjars
:
j
=
subjars
.
pop
()
j
=
subjars
.
pop
()
...
@@ -342,9 +342,9 @@ class Transaction:
...
@@ -342,9 +342,9 @@ class Transaction:
def
note
(
self
,
text
):
def
note
(
self
,
text
):
if
self
.
description
:
if
self
.
description
:
self
.
description
=
"%s
\
n
\
n
%s"
%
(
self
.
description
,
strip
(
text
))
self
.
description
=
"%s
\
n
\
n
%s"
%
(
self
.
description
,
strip
(
text
))
else
:
else
:
self
.
description
=
strip
(
text
)
self
.
description
=
strip
(
text
)
def
setUser
(
self
,
user_name
,
path
=
'/'
):
def
setUser
(
self
,
user_name
,
path
=
'/'
):
self
.
user
=
"%s %s"
%
(
path
,
user_name
)
self
.
user
=
"%s %s"
%
(
path
,
user_name
)
...
@@ -366,7 +366,7 @@ the application may not come up until you deal with
...
@@ -366,7 +366,7 @@ the application may not come up until you deal with
the system problem. See your application log for
the system problem. See your application log for
information on the error that lead to this problem.
information on the error that lead to this problem.
"""
"""
############################################################################
############################################################################
...
@@ -377,16 +377,16 @@ try:
...
@@ -377,16 +377,16 @@ try:
except
:
except
:
_t
=
Transaction
(
None
)
_t
=
Transaction
(
None
)
def
get_transaction
(
_t
=
_t
):
def
get_transaction
(
_t
=
_t
):
return
_t
return
_t
def
free_transaction
(
_t
=
_t
):
def
free_transaction
(
_t
=
_t
):
_t
.
__init__
()
_t
.
__init__
()
else
:
else
:
_t
=
{}
_t
=
{}
def
get_transaction
(
_id
=
thread
.
get_ident
,
_t
=
_t
,
get
=
_t
.
get
):
def
get_transaction
(
_id
=
thread
.
get_ident
,
_t
=
_t
,
get
=
_t
.
get
):
id
=
_id
()
id
=
_id
()
t
=
get
(
id
,
None
)
t
=
get
(
id
,
None
)
...
@@ -405,6 +405,5 @@ else:
...
@@ -405,6 +405,5 @@ else:
del
_t
del
_t
import
__main__
import
__main__
__main__
.
__builtins__
.
get_transaction
=
get_transaction
__main__
.
__builtins__
.
get_transaction
=
get_transaction
trunk/src/ZODB/UndoLogCompatible.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Provide backward compatability with storages that have undoLog, but not undoInfo."""
"""Provide backward compatability with storages that have undoLog, but not undoInfo."""
...
@@ -25,5 +25,5 @@ class UndoLogCompatible:
...
@@ -25,5 +25,5 @@ class UndoLogCompatible:
return
0
return
0
return
1
return
1
else
:
filter
=
None
else
:
filter
=
None
return
self
.
undoLog
(
first
,
last
,
filter
)
return
self
.
undoLog
(
first
,
last
,
filter
)
trunk/src/ZODB/ZApplication.py
View file @
bc40c6a3
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Implement an bobo_application object that is BoboPOS3 aware
"""Implement an bobo_application object that is BoboPOS3 aware
This module provides a wrapper that causes a database connection to be created
This module provides a wrapper that causes a database connection to be created
and used when bobo publishes a bobo_application object.
and used when bobo publishes a bobo_application object.
"""
"""
__version__
=
'$Revision: 1.1
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
StringType
=
type
(
''
)
StringType
=
type
(
''
)
connection_open_hooks
=
[]
connection_open_hooks
=
[]
...
@@ -34,7 +34,7 @@ class ZApplicationWrapper:
...
@@ -34,7 +34,7 @@ class ZApplicationWrapper:
get_transaction
().
commit
()
get_transaction
().
commit
()
conn
.
close
()
conn
.
close
()
self
.
_klass
=
klass
self
.
_klass
=
klass
# This hack is to overcome a bug in Bobo!
# This hack is to overcome a bug in Bobo!
def
__getattr__
(
self
,
name
):
def
__getattr__
(
self
,
name
):
...
@@ -57,16 +57,16 @@ class ZApplicationWrapper:
...
@@ -57,16 +57,16 @@ class ZApplicationWrapper:
REQUEST
.
_hold
(
cleanup
)
REQUEST
.
_hold
(
cleanup
)
conn
.
setDebugInfo
(
REQUEST
.
environ
,
REQUEST
.
other
)
conn
.
setDebugInfo
(
REQUEST
.
environ
,
REQUEST
.
other
)
v
=
conn
.
root
()[
aname
]
v
=
conn
.
root
()[
aname
]
if
name
is
not
None
:
if
name
is
not
None
:
if
hasattr
(
v
,
'__bobo_traverse__'
):
if
hasattr
(
v
,
'__bobo_traverse__'
):
return
v
.
__bobo_traverse__
(
REQUEST
,
name
)
return
v
.
__bobo_traverse__
(
REQUEST
,
name
)
if
hasattr
(
v
,
name
):
return
getattr
(
v
,
name
)
if
hasattr
(
v
,
name
):
return
getattr
(
v
,
name
)
return
v
[
name
]
return
v
[
name
]
return
v
return
v
...
@@ -77,9 +77,8 @@ class ZApplicationWrapper:
...
@@ -77,9 +77,8 @@ class ZApplicationWrapper:
connection
=
db
.
open
()
connection
=
db
.
open
()
elif
type
(
connection
)
is
StringType
:
elif
type
(
connection
)
is
StringType
:
connection
=
db
.
open
(
connection
)
connection
=
db
.
open
(
connection
)
return
connection
.
root
()[
aname
]
return
connection
.
root
()[
aname
]
class
Cleanup
:
pass
class
Cleanup
:
pass
trunk/src/ZODB/__init__.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
sys
,
ExtensionClass
,
TimeStamp
,
cPersistence
,
Persistence
import
sys
,
ExtensionClass
,
TimeStamp
,
cPersistence
,
Persistence
import
cStringIO
,
cPickle
import
cStringIO
,
cPickle
...
...
trunk/src/ZODB/bpthread.py
View file @
bc40c6a3
...
@@ -2,20 +2,20 @@
...
@@ -2,20 +2,20 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Thread abstraction module
"""Thread abstraction module
With this, we can run with or wothout threads.
With this, we can run with or wothout threads.
$Id: bpthread.py,v 1.
4 2002/02/11 23:40:42 gvanrossum
Exp $"""
$Id: bpthread.py,v 1.
5 2002/08/14 22:07:09 mj
Exp $"""
try
:
try
:
from
thread
import
*
from
thread
import
*
...
...
trunk/src/ZODB/conversionhack.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
PersistentMapping
import
PersistentMapping
...
...
trunk/src/ZODB/dbmStorage.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Very Simple dbm-based ZODB storage
"""Very Simple dbm-based ZODB storage
...
@@ -18,7 +18,7 @@ don't support versions or Undo. This may be useful when implementing
...
@@ -18,7 +18,7 @@ don't support versions or Undo. This may be useful when implementing
objects like hit counters that don't need or want to participate
objects like hit counters that don't need or want to participate
in undo or versions.
in undo or versions.
"""
"""
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
import
base64
,
POSException
,
time
,
string
,
utils
import
base64
,
POSException
,
time
,
string
,
utils
...
@@ -40,7 +40,7 @@ class anydbmStorage(MappingStorage):
...
@@ -40,7 +40,7 @@ class anydbmStorage(MappingStorage):
def
getSize
(
self
):
def
getSize
(
self
):
# This is a little iffy, since we aren't entirely sure what the file is
# This is a little iffy, since we aren't entirely sure what the file is
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
try
:
try
:
return
(
os
.
stat
(
self
.
__name__
+
'.data'
)[
6
]
+
return
(
os
.
stat
(
self
.
__name__
+
'.data'
)[
6
]
+
os
.
stat
(
self
.
__name__
+
'.dir'
)[
6
]
os
.
stat
(
self
.
__name__
+
'.dir'
)[
6
]
...
@@ -73,9 +73,9 @@ class gdbmStorage(anydbmStorage):
...
@@ -73,9 +73,9 @@ class gdbmStorage(anydbmStorage):
finally
:
self
.
_lock_release
()
finally
:
self
.
_lock_release
()
def
pack
(
self
,
t
,
referencesf
):
def
pack
(
self
,
t
,
referencesf
):
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
# Build an index of *only* those objects reachable
# Build an index of *only* those objects reachable
# from the root.
# from the root.
index
=
self
.
_index
index
=
self
.
_index
...
@@ -86,7 +86,7 @@ class gdbmStorage(anydbmStorage):
...
@@ -86,7 +86,7 @@ class gdbmStorage(anydbmStorage):
while
rootl
:
while
rootl
:
oid
=
pop
()
oid
=
pop
()
if
referenced
(
oid
):
continue
if
referenced
(
oid
):
continue
# Scan non-version pickle for references
# Scan non-version pickle for references
r
=
index
[
oid
]
r
=
index
[
oid
]
pindex
[
oid
]
=
r
pindex
[
oid
]
=
r
...
@@ -107,7 +107,7 @@ class gdbmStorage(anydbmStorage):
...
@@ -107,7 +107,7 @@ class gdbmStorage(anydbmStorage):
index
.
sync
()
index
.
sync
()
index
.
reorganize
()
index
.
reorganize
()
finally
:
self
.
_lock_release
()
finally
:
self
.
_lock_release
()
...
...
trunk/src/ZODB/fsIndex.py
View file @
bc40c6a3
...
@@ -2,33 +2,33 @@
...
@@ -2,33 +2,33 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Implement an OID to File-position (long integer) mapping
"""Implement an OID to File-position (long integer) mapping
"""
"""
#
#
# To save space, we do two things:
# To save space, we do two things:
#
#
# 1. We split the keys (OIDS) into 6-byte prefixes and 2-byte suffixes.
# 1. We split the keys (OIDS) into 6-byte prefixes and 2-byte suffixes.
# We use the prefixes as keys in a mapping from prefix to mappings
# We use the prefixes as keys in a mapping from prefix to mappings
# of suffix to data:
# of suffix to data:
#
#
# data is {prefix -> {suffix -> data}}
# data is {prefix -> {suffix -> data}}
#
#
# 2. We limit the data size to 48 bits. This should allow databases
# 2. We limit the data size to 48 bits. This should allow databases
# as large as 256 terabytes.
# as large as 256 terabytes.
#
#
# Mostof the space is consumed by items in the mappings from 2-byte
# Mostof the space is consumed by items in the mappings from 2-byte
# suffix to 6-byte data. This should reduce the overall memory usage to
# suffix to 6-byte data. This should reduce the overall memory usage to
# 8-16 bytes per OID.
# 8-16 bytes per OID.
#
#
# We use p64 to convert integers to 8-byte strings and lop off the two
# We use p64 to convert integers to 8-byte strings and lop off the two
# high-order bytes when saving. On loading data, we add the leading
# high-order bytes when saving. On loading data, we add the leading
# bytes back before using U64 to convert the data back to (long)
# bytes back before using U64 to convert the data back to (long)
...
@@ -51,7 +51,7 @@ def str2num(s):
...
@@ -51,7 +51,7 @@ def str2num(s):
if
h
:
if
h
:
return
(
long
(
h
)
<<
32
)
+
l
return
(
long
(
h
)
<<
32
)
+
l
else
:
else
:
return
l
return
l
class
fsIndex
:
class
fsIndex
:
...
...
trunk/src/ZODB/fsrecover.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
...
@@ -49,14 +49,14 @@ Options:
...
@@ -49,14 +49,14 @@ Options:
Pack data to t seconds in the past. Note that is the "-p"
Pack data to t seconds in the past. Note that is the "-p"
option is used, then t should be 0.
option is used, then t should be 0.
Important note: The ZODB package must be imporable. You may need
Important note: The ZODB package must be imporable. You may need
to adjust the Python path accordingly.
to adjust the Python path accordingly.
"""
"""
# Algorithm:
# Algorithm:
#
#
# position to start of input
# position to start of input
# while 1:
# while 1:
# if end of file: break
# if end of file: break
...
@@ -81,7 +81,7 @@ except ImportError:
...
@@ -81,7 +81,7 @@ except ImportError:
elif
os
.
path
.
exists
(
'FileStorage.py'
):
sys
.
path
.
append
(
'..'
)
elif
os
.
path
.
exists
(
'FileStorage.py'
):
sys
.
path
.
append
(
'..'
)
import
ZODB
import
ZODB
import
getopt
,
ZODB
.
FileStorage
,
struct
,
time
import
getopt
,
ZODB
.
FileStorage
,
struct
,
time
from
struct
import
unpack
from
struct
import
unpack
from
ZODB.utils
import
t32
,
p64
,
U64
from
ZODB.utils
import
t32
,
p64
,
U64
...
@@ -185,7 +185,7 @@ def iprogress(i):
...
@@ -185,7 +185,7 @@ def iprogress(i):
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
def
progress
(
p
):
def
progress
(
p
):
for
i
in
range
(
p
):
iprogress
(
i
)
for
i
in
range
(
p
):
iprogress
(
i
)
def
recover
(
argv
=
sys
.
argv
):
def
recover
(
argv
=
sys
.
argv
):
...
@@ -199,7 +199,7 @@ def recover(argv=sys.argv):
...
@@ -199,7 +199,7 @@ def recover(argv=sys.argv):
elif
opt
==
'-f'
:
force
=
1
elif
opt
==
'-f'
:
force
=
1
elif
opt
==
'-P'
:
pack
=
time
.
time
()
-
float
(
v
)
elif
opt
==
'-P'
:
pack
=
time
.
time
()
-
float
(
v
)
force
=
filter
(
lambda
opt
:
opt
[
0
]
==
'-f'
,
opts
)
force
=
filter
(
lambda
opt
:
opt
[
0
]
==
'-f'
,
opts
)
partial
=
filter
(
lambda
opt
:
opt
[
0
]
==
'-p'
,
opts
)
partial
=
filter
(
lambda
opt
:
opt
[
0
]
==
'-p'
,
opts
)
verbose
=
filter
(
lambda
opt
:
opt
[
0
]
==
'-v'
,
opts
)
verbose
=
filter
(
lambda
opt
:
opt
[
0
]
==
'-v'
,
opts
)
...
@@ -208,7 +208,7 @@ def recover(argv=sys.argv):
...
@@ -208,7 +208,7 @@ def recover(argv=sys.argv):
except
:
except
:
die
()
die
()
print
__doc__
%
argv
[
0
]
print
__doc__
%
argv
[
0
]
if
os
.
path
.
exists
(
outp
)
and
not
force
:
if
os
.
path
.
exists
(
outp
)
and
not
force
:
die
(
"%s exists"
%
outp
)
die
(
"%s exists"
%
outp
)
...
@@ -267,7 +267,7 @@ def recover(argv=sys.argv):
...
@@ -267,7 +267,7 @@ def recover(argv=sys.argv):
ok
=
1
ok
=
1
if
verbose
:
if
verbose
:
print
'begin'
,
print
'begin'
,
if
verbose
>
1
:
print
if
verbose
>
1
:
print
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
...
@@ -317,14 +317,13 @@ def recover(argv=sys.argv):
...
@@ -317,14 +317,13 @@ def recover(argv=sys.argv):
print
"
\
n
%s bytes removed during recovery"
%
bad
print
"
\
n
%s bytes removed during recovery"
%
bad
if
undone
:
if
undone
:
print
"%s bytes of undone transaction data were skipped"
%
undone
print
"%s bytes of undone transaction data were skipped"
%
undone
if
pack
is
not
None
:
if
pack
is
not
None
:
print
"Packing ..."
print
"Packing ..."
from
ZODB.referencesf
import
referencesf
from
ZODB.referencesf
import
referencesf
ofs
.
pack
(
pack
,
referencesf
)
ofs
.
pack
(
pack
,
referencesf
)
ofs
.
close
()
ofs
.
close
()
if
__name__
==
'__main__'
:
recover
()
if
__name__
==
'__main__'
:
recover
()
trunk/src/ZODB/lock_file.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
POSException
import
POSException
...
@@ -44,15 +44,14 @@ except:
...
@@ -44,15 +44,14 @@ except:
un
=
file
.
fileno
()
un
=
file
.
fileno
()
except
:
except
:
return
# don't care if not a real file
return
# don't care if not a real file
try
:
try
:
LockFile
(
un
,
0
,
0
,
1
,
0
)
# just lock the first byte, who cares
LockFile
(
un
,
0
,
0
,
1
,
0
)
# just lock the first byte, who cares
except
:
except
:
raise
error
,
(
raise
error
,
(
"Could not lock the database file. There must be
\
n
"
"Could not lock the database file. There must be
\
n
"
"another process that has opened the file.
\
n
"
"another process that has opened the file.
\
n
"
"<p>"
)
"<p>"
)
except
:
except
:
def
lock_file
(
file
,
error
=
None
):
def
lock_file
(
file
,
error
=
None
):
pass
pass
trunk/src/ZODB/referencesf.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Provide a function that can find object references in pickles
"""Provide a function that can find object references in pickles
"""
"""
...
...
trunk/src/ZODB/tests/BasicStorage.py
View file @
bc40c6a3
...
@@ -16,7 +16,7 @@ from ZODB.tests.StorageTestBase \
...
@@ -16,7 +16,7 @@ from ZODB.tests.StorageTestBase \
ZERO
=
'
\
0
'
*
8
ZERO
=
'
\
0
'
*
8
class
BasicStorage
:
class
BasicStorage
:
def
checkBasics
(
self
):
def
checkBasics
(
self
):
t
=
Transaction
()
t
=
Transaction
()
...
...
trunk/src/ZODB/tests/ConflictResolution.py
View file @
bc40c6a3
...
@@ -59,7 +59,7 @@ class ConflictResolvingStorage:
...
@@ -59,7 +59,7 @@ class ConflictResolvingStorage:
obj
.
inc
()
obj
.
inc
()
# The effect of committing two transactions with the same
# The effect of committing two transactions with the same
# pickle is to commit two different transactions relative to
# pickle is to commit two different transactions relative to
# revid1 that add two to _value.
# revid1 that add two to _value.
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
revid3
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
revid3
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
...
@@ -79,7 +79,7 @@ class ConflictResolvingStorage:
...
@@ -79,7 +79,7 @@ class ConflictResolvingStorage:
obj
.
inc
()
obj
.
inc
()
# The effect of committing two transactions with the same
# The effect of committing two transactions with the same
# pickle is to commit two different transactions relative to
# pickle is to commit two different transactions relative to
# revid1 that add two to _value.
# revid1 that add two to _value.
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
self
.
assertRaises
(
ConflictError
,
self
.
assertRaises
(
ConflictError
,
self
.
_dostoreNP
,
self
.
_dostoreNP
,
...
@@ -89,7 +89,7 @@ class ConflictResolvingStorage:
...
@@ -89,7 +89,7 @@ class ConflictResolvingStorage:
from
ZODB.ConflictResolution
import
bad_class
from
ZODB.ConflictResolution
import
bad_class
dummy_class_tuple
=
(
'*foobar'
,
())
dummy_class_tuple
=
(
'*foobar'
,
())
assert
bad_class
(
dummy_class_tuple
)
==
1
assert
bad_class
(
dummy_class_tuple
)
==
1
def
checkBuggyResolve1
(
self
):
def
checkBuggyResolve1
(
self
):
obj
=
PCounter3
()
obj
=
PCounter3
()
obj
.
inc
()
obj
.
inc
()
...
@@ -102,7 +102,7 @@ class ConflictResolvingStorage:
...
@@ -102,7 +102,7 @@ class ConflictResolvingStorage:
obj
.
inc
()
obj
.
inc
()
# The effect of committing two transactions with the same
# The effect of committing two transactions with the same
# pickle is to commit two different transactions relative to
# pickle is to commit two different transactions relative to
# revid1 that add two to _value.
# revid1 that add two to _value.
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
self
.
assertRaises
(
AttributeError
,
self
.
assertRaises
(
AttributeError
,
self
.
_dostoreNP
,
self
.
_dostoreNP
,
...
@@ -120,7 +120,7 @@ class ConflictResolvingStorage:
...
@@ -120,7 +120,7 @@ class ConflictResolvingStorage:
obj
.
inc
()
obj
.
inc
()
# The effect of committing two transactions with the same
# The effect of committing two transactions with the same
# pickle is to commit two different transactions relative to
# pickle is to commit two different transactions relative to
# revid1 that add two to _value.
# revid1 that add two to _value.
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
revid2
=
self
.
_dostoreNP
(
oid
,
revid
=
revid1
,
data
=
zodb_pickle
(
obj
))
self
.
assertRaises
(
TypeError
,
self
.
assertRaises
(
TypeError
,
self
.
_dostoreNP
,
self
.
_dostoreNP
,
...
@@ -132,7 +132,7 @@ class ConflictResolvingTransUndoStorage:
...
@@ -132,7 +132,7 @@ class ConflictResolvingTransUndoStorage:
# This test is based on checkNotUndoable in the
# This test is based on checkNotUndoable in the
# 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.
obj
=
PCounter
()
obj
=
PCounter
()
obj
.
inc
()
obj
.
inc
()
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
...
@@ -153,7 +153,7 @@ class ConflictResolvingTransUndoStorage:
...
@@ -153,7 +153,7 @@ class ConflictResolvingTransUndoStorage:
# This test is based on checkNotUndoable in the
# This test is based on checkNotUndoable in the
# 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.
obj
=
PCounter2
()
obj
=
PCounter2
()
obj
.
inc
()
obj
.
inc
()
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
...
@@ -170,4 +170,3 @@ class ConflictResolvingTransUndoStorage:
...
@@ -170,4 +170,3 @@ class ConflictResolvingTransUndoStorage:
self
.
assertRaises
(
UndoError
,
self
.
_storage
.
transactionalUndo
,
self
.
assertRaises
(
UndoError
,
self
.
_storage
.
transactionalUndo
,
tid
,
t
)
tid
,
t
)
self
.
_storage
.
tpc_abort
(
t
)
self
.
_storage
.
tpc_abort
(
t
)
trunk/src/ZODB/tests/Corruption.py
View file @
bc40c6a3
...
@@ -35,7 +35,7 @@ class FileStorageCorruptTests(StorageTestBase):
...
@@ -35,7 +35,7 @@ class FileStorageCorruptTests(StorageTestBase):
def
checkTruncatedIndex
(
self
):
def
checkTruncatedIndex
(
self
):
oids
=
self
.
_do_stores
()
oids
=
self
.
_do_stores
()
self
.
_close
()
self
.
_close
()
# truncation the index file
# truncation the index file
path
=
self
.
path
+
'.index'
path
=
self
.
path
+
'.index'
self
.
failUnless
(
os
.
path
.
exists
(
path
))
self
.
failUnless
(
os
.
path
.
exists
(
path
))
...
@@ -52,7 +52,7 @@ class FileStorageCorruptTests(StorageTestBase):
...
@@ -52,7 +52,7 @@ class FileStorageCorruptTests(StorageTestBase):
def
checkCorruptedIndex
(
self
):
def
checkCorruptedIndex
(
self
):
oids
=
self
.
_do_stores
()
oids
=
self
.
_do_stores
()
self
.
_close
()
self
.
_close
()
# truncation the index file
# truncation the index file
path
=
self
.
path
+
'.index'
path
=
self
.
path
+
'.index'
self
.
failUnless
(
os
.
path
.
exists
(
path
))
self
.
failUnless
(
os
.
path
.
exists
(
path
))
...
...
trunk/src/ZODB/tests/HistoryStorage.py
View file @
bc40c6a3
...
@@ -9,7 +9,7 @@ from ZODB.tests.MinPO import MinPO
...
@@ -9,7 +9,7 @@ from ZODB.tests.MinPO import MinPO
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
class
HistoryStorage
:
class
HistoryStorage
:
def
checkSimpleHistory
(
self
):
def
checkSimpleHistory
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
trunk/src/ZODB/tests/IteratorStorage.py
View file @
bc40c6a3
...
@@ -9,7 +9,7 @@ from ZODB.tests.StorageTestBase import zodb_unpickle
...
@@ -9,7 +9,7 @@ from ZODB.tests.StorageTestBase import zodb_unpickle
from
ZODB.utils
import
U64
,
p64
from
ZODB.utils
import
U64
,
p64
from
ZODB.Transaction
import
Transaction
from
ZODB.Transaction
import
Transaction
class
IteratorCompare
:
class
IteratorCompare
:
def
iter_verify
(
self
,
txniter
,
revids
,
val0
):
def
iter_verify
(
self
,
txniter
,
revids
,
val0
):
...
...
trunk/src/ZODB/tests/MTStorage.py
View file @
bc40c6a3
...
@@ -173,7 +173,7 @@ class MTStorage:
...
@@ -173,7 +173,7 @@ class MTStorage:
t
.
join
(
10
)
t
.
join
(
10
)
for
t
in
threads
:
for
t
in
threads
:
self
.
failIf
(
t
.
isAlive
())
self
.
failIf
(
t
.
isAlive
())
def
check2ZODBThreads
(
self
):
def
check2ZODBThreads
(
self
):
db
=
ZODB
.
DB
(
self
.
_storage
)
db
=
ZODB
.
DB
(
self
.
_storage
)
self
.
_checkNThreads
(
2
,
ZODBClientThread
,
db
,
self
)
self
.
_checkNThreads
(
2
,
ZODBClientThread
,
db
,
self
)
...
@@ -184,10 +184,9 @@ class MTStorage:
...
@@ -184,10 +184,9 @@ class MTStorage:
def
check2StorageThreads
(
self
):
def
check2StorageThreads
(
self
):
self
.
_checkNThreads
(
2
,
StorageClientThread
,
self
.
_storage
,
self
)
self
.
_checkNThreads
(
2
,
StorageClientThread
,
self
.
_storage
,
self
)
def
check7StorageThreads
(
self
):
def
check7StorageThreads
(
self
):
self
.
_checkNThreads
(
7
,
StorageClientThread
,
self
.
_storage
,
self
)
self
.
_checkNThreads
(
7
,
StorageClientThread
,
self
.
_storage
,
self
)
def
check4ExtStorageThread
(
self
):
def
check4ExtStorageThread
(
self
):
self
.
_checkNThreads
(
4
,
ExtStorageClientThread
,
self
.
_storage
,
self
)
self
.
_checkNThreads
(
4
,
ExtStorageClientThread
,
self
.
_storage
,
self
)
trunk/src/ZODB/tests/PackableStorage.py
View file @
bc40c6a3
...
@@ -18,7 +18,7 @@ from ZODB.referencesf import referencesf
...
@@ -18,7 +18,7 @@ from ZODB.referencesf import referencesf
ZERO
=
'
\
0
'
*
8
ZERO
=
'
\
0
'
*
8
# This class is for the root object. It must not contain a getoid() method
# This class is for the root object. It must not contain a getoid() method
# (really, attribute). The persistent pickling machinery -- in the dumps()
# (really, attribute). The persistent pickling machinery -- in the dumps()
# function below -- will pickle Root objects as normal, but any attributes
# function below -- will pickle Root objects as normal, but any attributes
...
@@ -64,7 +64,7 @@ def dumps(obj):
...
@@ -64,7 +64,7 @@ def dumps(obj):
return
s
.
getvalue
()
return
s
.
getvalue
()
class
PackableStorageBase
:
class
PackableStorageBase
:
# We keep a cache of object ids to instances so that the unpickler can
# We keep a cache of object ids to instances so that the unpickler can
# easily return any persistent object.
# easily return any persistent object.
...
@@ -100,7 +100,7 @@ class PackableStorageBase:
...
@@ -100,7 +100,7 @@ class PackableStorageBase:
return
loads
return
loads
class
PackableStorage
(
PackableStorageBase
):
class
PackableStorage
(
PackableStorageBase
):
def
_initroot
(
self
):
def
_initroot
(
self
):
try
:
try
:
...
@@ -125,11 +125,11 @@ class PackableStorage(PackableStorageBase):
...
@@ -125,11 +125,11 @@ class PackableStorage(PackableStorageBase):
def
checkPackTomorrow
(
self
):
def
checkPackTomorrow
(
self
):
self
.
_initroot
()
self
.
_initroot
()
self
.
_storage
.
pack
(
time
.
time
()
+
10000
,
referencesf
)
self
.
_storage
.
pack
(
time
.
time
()
+
10000
,
referencesf
)
def
checkPackYesterday
(
self
):
def
checkPackYesterday
(
self
):
self
.
_initroot
()
self
.
_initroot
()
self
.
_storage
.
pack
(
time
.
time
()
-
10000
,
referencesf
)
self
.
_storage
.
pack
(
time
.
time
()
-
10000
,
referencesf
)
def
checkPackAllRevisions
(
self
):
def
checkPackAllRevisions
(
self
):
self
.
_initroot
()
self
.
_initroot
()
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
trunk/src/ZODB/tests/PersistentStorage.py
View file @
bc40c6a3
...
@@ -4,7 +4,7 @@ class PersistentStorage:
...
@@ -4,7 +4,7 @@ class PersistentStorage:
def
checkUpdatesPersist
(
self
):
def
checkUpdatesPersist
(
self
):
oids
=
[]
oids
=
[]
def
new_oid_wrapper
(
l
=
oids
,
new_oid
=
self
.
_storage
.
new_oid
):
def
new_oid_wrapper
(
l
=
oids
,
new_oid
=
self
.
_storage
.
new_oid
):
oid
=
new_oid
()
oid
=
new_oid
()
l
.
append
(
oid
)
l
.
append
(
oid
)
...
@@ -31,7 +31,7 @@ class PersistentStorage:
...
@@ -31,7 +31,7 @@ class PersistentStorage:
if
ver
:
if
ver
:
p
,
s
=
self
.
_storage
.
load
(
oid
,
ver
)
p
,
s
=
self
.
_storage
.
load
(
oid
,
ver
)
objects
.
append
((
oid
,
ver
,
p
,
s
))
objects
.
append
((
oid
,
ver
,
p
,
s
))
self
.
_storage
.
close
()
self
.
_storage
.
close
()
self
.
open
()
self
.
open
()
...
...
trunk/src/ZODB/tests/ReadOnlyStorage.py
View file @
bc40c6a3
...
@@ -38,7 +38,7 @@ class ReadOnlyStorage:
...
@@ -38,7 +38,7 @@ class ReadOnlyStorage:
self
.
assertRaises
(
ReadOnlyError
,
self
.
_storage
.
abortVersion
,
self
.
assertRaises
(
ReadOnlyError
,
self
.
_storage
.
abortVersion
,
''
,
t
)
''
,
t
)
self
.
_storage
.
tpc_abort
(
t
)
self
.
_storage
.
tpc_abort
(
t
)
t
=
Transaction
()
t
=
Transaction
()
self
.
_storage
.
tpc_begin
(
t
)
self
.
_storage
.
tpc_begin
(
t
)
self
.
assertRaises
(
ReadOnlyError
,
self
.
_storage
.
commitVersion
,
self
.
assertRaises
(
ReadOnlyError
,
self
.
_storage
.
commitVersion
,
...
@@ -57,5 +57,3 @@ class ReadOnlyStorage:
...
@@ -57,5 +57,3 @@ class ReadOnlyStorage:
self
.
assertRaises
(
ReadOnlyError
,
self
.
_storage
.
transactionalUndo
,
self
.
assertRaises
(
ReadOnlyError
,
self
.
_storage
.
transactionalUndo
,
'
\
000
'
*
8
,
t
)
'
\
000
'
*
8
,
t
)
self
.
_storage
.
tpc_abort
(
t
)
self
.
_storage
.
tpc_abort
(
t
)
trunk/src/ZODB/tests/RevisionStorage.py
View file @
bc40c6a3
...
@@ -6,7 +6,7 @@ from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
...
@@ -6,7 +6,7 @@ from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
ZERO
=
'
\
0
'
*
8
ZERO
=
'
\
0
'
*
8
class
RevisionStorage
:
class
RevisionStorage
:
def
checkLoadSerial
(
self
):
def
checkLoadSerial
(
self
):
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
revid
=
ZERO
revid
=
ZERO
...
@@ -18,4 +18,3 @@ class RevisionStorage:
...
@@ -18,4 +18,3 @@ class RevisionStorage:
for
revid
,
value
in
revisions
.
items
():
for
revid
,
value
in
revisions
.
items
():
data
=
self
.
_storage
.
loadSerial
(
oid
,
revid
)
data
=
self
.
_storage
.
loadSerial
(
oid
,
revid
)
self
.
assertEqual
(
zodb_unpickle
(
data
),
value
)
self
.
assertEqual
(
zodb_unpickle
(
data
),
value
)
trunk/src/ZODB/tests/StorageTestBase.py
View file @
bc40c6a3
...
@@ -116,13 +116,13 @@ def removefs(base):
...
@@ -116,13 +116,13 @@ def removefs(base):
except
os
.
error
,
err
:
except
os
.
error
,
err
:
if
err
[
0
]
!=
errno
.
ENOENT
:
if
err
[
0
]
!=
errno
.
ENOENT
:
raise
raise
class
StorageTestBase
(
unittest
.
TestCase
):
class
StorageTestBase
(
unittest
.
TestCase
):
# XXX It would be simpler if concrete tests didn't need to extend
# XXX It would be simpler if concrete tests didn't need to extend
# setUp() and tearDown().
# setUp() and tearDown().
def
setUp
(
self
):
def
setUp
(
self
):
# You need to override this with a setUp that creates self._storage
# You need to override this with a setUp that creates self._storage
self
.
_storage
=
None
self
.
_storage
=
None
...
@@ -139,12 +139,12 @@ class StorageTestBase(unittest.TestCase):
...
@@ -139,12 +139,12 @@ class StorageTestBase(unittest.TestCase):
def
_dostore
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
,
def
_dostore
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
,
already_pickled
=
0
,
user
=
None
,
description
=
None
):
already_pickled
=
0
,
user
=
None
,
description
=
None
):
"""Do a complete storage transaction. The defaults are:
"""Do a complete storage transaction. The defaults are:
- oid=None, ask the storage for a new oid
- oid=None, ask the storage for a new oid
- revid=None, use a revid of ZERO
- revid=None, use a revid of ZERO
- data=None, pickle up some arbitrary data (the integer 7)
- data=None, pickle up some arbitrary data (the integer 7)
- version=None, use the empty string version
- version=None, use the empty string version
Returns the object's new revision id.
Returns the object's new revision id.
"""
"""
if
oid
is
None
:
if
oid
is
None
:
...
@@ -177,7 +177,7 @@ class StorageTestBase(unittest.TestCase):
...
@@ -177,7 +177,7 @@ class StorageTestBase(unittest.TestCase):
self
.
_storage
.
tpc_abort
(
t
)
self
.
_storage
.
tpc_abort
(
t
)
raise
raise
return
revid
return
revid
def
_dostoreNP
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
,
def
_dostoreNP
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
,
user
=
None
,
description
=
None
):
user
=
None
,
description
=
None
):
return
self
.
_dostore
(
oid
,
revid
,
data
,
version
,
already_pickled
=
1
)
return
self
.
_dostore
(
oid
,
revid
,
data
,
version
,
already_pickled
=
1
)
trunk/src/ZODB/tests/Synchronization.py
View file @
bc40c6a3
...
@@ -61,7 +61,7 @@ class SynchronizedStorage:
...
@@ -61,7 +61,7 @@ class SynchronizedStorage:
## def verifyCommitting(self, callable, *args):
## def verifyCommitting(self, callable, *args):
## self.assertRaises(StorageTransactionError, callable *args)
## self.assertRaises(StorageTransactionError, callable *args)
def
verifyNotCommitting
(
self
,
callable
,
*
args
):
def
verifyNotCommitting
(
self
,
callable
,
*
args
):
args
=
(
StorageTransactionError
,
callable
)
+
args
args
=
(
StorageTransactionError
,
callable
)
+
args
apply
(
self
.
assertRaises
,
args
)
apply
(
self
.
assertRaises
,
args
)
...
@@ -92,17 +92,17 @@ class SynchronizedStorage:
...
@@ -92,17 +92,17 @@ class SynchronizedStorage:
def
checkStoreNotCommitting
(
self
):
def
checkStoreNotCommitting
(
self
):
self
.
verifyNotCommitting
(
self
.
_storage
.
store
,
self
.
verifyNotCommitting
(
self
.
_storage
.
store
,
OID
,
SERIALNO
,
""
,
""
,
Transaction
())
OID
,
SERIALNO
,
""
,
""
,
Transaction
())
def
checkStoreWrongTrans
(
self
):
def
checkStoreWrongTrans
(
self
):
self
.
verifyWrongTrans
(
self
.
_storage
.
store
,
self
.
verifyWrongTrans
(
self
.
_storage
.
store
,
OID
,
SERIALNO
,
""
,
""
,
Transaction
())
OID
,
SERIALNO
,
""
,
""
,
Transaction
())
## def checkNewOidNotCommitting(self):
## def checkNewOidNotCommitting(self):
## self.verifyNotCommitting(self._storage.new_oid)
## self.verifyNotCommitting(self._storage.new_oid)
## def checkNewOidWrongTrans(self):
## def checkNewOidWrongTrans(self):
## self.verifyWrongTrans(self._storage.new_oid)
## self.verifyWrongTrans(self._storage.new_oid)
def
checkAbortNotCommitting
(
self
):
def
checkAbortNotCommitting
(
self
):
self
.
_storage
.
tpc_abort
(
Transaction
())
self
.
_storage
.
tpc_abort
(
Transaction
())
...
@@ -123,7 +123,7 @@ class SynchronizedStorage:
...
@@ -123,7 +123,7 @@ class SynchronizedStorage:
self
.
_storage
.
tpc_begin
(
t
)
self
.
_storage
.
tpc_begin
(
t
)
self
.
_storage
.
tpc_finish
(
Transaction
())
self
.
_storage
.
tpc_finish
(
Transaction
())
self
.
_storage
.
tpc_abort
(
t
)
self
.
_storage
.
tpc_abort
(
t
)
def
checkBeginCommitting
(
self
):
def
checkBeginCommitting
(
self
):
t
=
Transaction
()
t
=
Transaction
()
self
.
_storage
.
tpc_begin
(
t
)
self
.
_storage
.
tpc_begin
(
t
)
...
...
trunk/src/ZODB/tests/TransactionalUndoStorage.py
View file @
bc40c6a3
...
@@ -51,7 +51,7 @@ class TransactionalUndoStorage:
...
@@ -51,7 +51,7 @@ class TransactionalUndoStorage:
for
oid
in
newrevs
.
keys
():
for
oid
in
newrevs
.
keys
():
newrevs
[
oid
]
=
self
.
_transaction_newserial
(
oid
)
newrevs
[
oid
]
=
self
.
_transaction_newserial
(
oid
)
return
newrevs
return
newrevs
def
checkSimpleTransactionalUndo
(
self
):
def
checkSimpleTransactionalUndo
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
...
@@ -366,7 +366,7 @@ class TransactionalUndoStorage:
...
@@ -366,7 +366,7 @@ class TransactionalUndoStorage:
eq
(
zodb_unpickle
(
data
),
MinPO
(
33
))
eq
(
zodb_unpickle
(
data
),
MinPO
(
33
))
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
data
,
revid2
=
self
.
_storage
.
load
(
oid2
,
''
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
54
))
eq
(
zodb_unpickle
(
data
),
MinPO
(
54
))
def
checkNotUndoable
(
self
):
def
checkNotUndoable
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
trunk/src/ZODB/tests/TransactionalUndoVersionStorage.py
View file @
bc40c6a3
...
@@ -11,7 +11,7 @@ from ZODB.Transaction import Transaction
...
@@ -11,7 +11,7 @@ from ZODB.Transaction import Transaction
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
class
TransactionalUndoVersionStorage
:
class
TransactionalUndoVersionStorage
:
def
_x_dostore
(
self
,
*
args
,
**
kwargs
):
def
_x_dostore
(
self
,
*
args
,
**
kwargs
):
...
@@ -28,7 +28,7 @@ class TransactionalUndoVersionStorage:
...
@@ -28,7 +28,7 @@ class TransactionalUndoVersionStorage:
except
KeyError
:
except
KeyError
:
pass
# not expected
pass
# not expected
return
self
.
_dostore
(
*
args
,
**
kwargs
)
return
self
.
_dostore
(
*
args
,
**
kwargs
)
def
checkUndoInVersion
(
self
):
def
checkUndoInVersion
(
self
):
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
version
=
'one'
version
=
'one'
...
@@ -129,7 +129,7 @@ class TransactionalUndoVersionStorage:
...
@@ -129,7 +129,7 @@ class TransactionalUndoVersionStorage:
revid
=
self
.
_x_dostore
(
oid
,
revid
,
description
=
'packable%d'
%
i
)
revid
=
self
.
_x_dostore
(
oid
,
revid
,
description
=
'packable%d'
%
i
)
pt
=
time
.
time
()
pt
=
time
.
time
()
time
.
sleep
(
1
)
time
.
sleep
(
1
)
oid1
=
self
.
_storage
.
new_oid
()
oid1
=
self
.
_storage
.
new_oid
()
version
=
'version'
version
=
'version'
revid1
=
self
.
_x_dostore
(
oid1
,
data
=
MinPO
(
0
),
description
=
'create1'
)
revid1
=
self
.
_x_dostore
(
oid1
,
data
=
MinPO
(
0
),
description
=
'create1'
)
...
@@ -176,7 +176,7 @@ class TransactionalUndoVersionStorage:
...
@@ -176,7 +176,7 @@ class TransactionalUndoVersionStorage:
revid
=
self
.
_x_dostore
(
oid
,
revid
,
description
=
'packable%d'
%
i
)
revid
=
self
.
_x_dostore
(
oid
,
revid
,
description
=
'packable%d'
%
i
)
pt
=
time
.
time
()
pt
=
time
.
time
()
time
.
sleep
(
1
)
time
.
sleep
(
1
)
oid1
=
self
.
_storage
.
new_oid
()
oid1
=
self
.
_storage
.
new_oid
()
version
=
'version'
version
=
'version'
revid1
=
self
.
_x_dostore
(
oid1
,
data
=
MinPO
(
0
),
description
=
'create1'
)
revid1
=
self
.
_x_dostore
(
oid1
,
data
=
MinPO
(
0
),
description
=
'create1'
)
...
@@ -227,4 +227,3 @@ class TransactionalUndoVersionStorage:
...
@@ -227,4 +227,3 @@ class TransactionalUndoVersionStorage:
self
.
assertEqual
(
load_value
(
oid1
),
0
)
self
.
assertEqual
(
load_value
(
oid1
),
0
)
# after abort, we should see non-version data
# after abort, we should see non-version data
self
.
assertEqual
(
load_value
(
oid1
,
version
),
0
)
self
.
assertEqual
(
load_value
(
oid1
,
version
),
0
)
trunk/src/ZODB/tests/VersionStorage.py
View file @
bc40c6a3
...
@@ -12,7 +12,7 @@ from ZODB.Transaction import Transaction
...
@@ -12,7 +12,7 @@ from ZODB.Transaction import Transaction
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
class
VersionStorage
:
class
VersionStorage
:
def
checkVersionedStoreAndLoad
(
self
):
def
checkVersionedStoreAndLoad
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
@@ -23,7 +23,7 @@ class VersionStorage:
...
@@ -23,7 +23,7 @@ class VersionStorage:
# And now store some new revisions in a version
# And now store some new revisions in a version
version
=
'test-version'
version
=
'test-version'
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
MinPO
(
13
),
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
MinPO
(
13
),
version
=
version
)
version
=
version
)
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
MinPO
(
14
),
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
MinPO
(
14
),
version
=
version
)
version
=
version
)
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
MinPO
(
15
),
revid
=
self
.
_dostore
(
oid
,
revid
=
revid
,
data
=
MinPO
(
15
),
...
@@ -137,12 +137,12 @@ class VersionStorage:
...
@@ -137,12 +137,12 @@ class VersionStorage:
def
checkAbortVersion
(
self
):
def
checkAbortVersion
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
oid
,
version
=
self
.
_setup_version
()
oid
,
version
=
self
.
_setup_version
()
# XXX Not sure I can write a test for getSerial() in the
# XXX Not sure I can write a test for getSerial() in the
# presence of aborted versions, because FileStorage and
# presence of aborted versions, because FileStorage and
# Berkeley storage give a different answer. I think Berkeley
# Berkeley storage give a different answer. I think Berkeley
# is right and FS is wrong.
# is right and FS is wrong.
## s1 = self._storage.getSerial(oid)
## s1 = self._storage.getSerial(oid)
# Now abort the version -- must be done in a transaction
# Now abort the version -- must be done in a transaction
t
=
Transaction
()
t
=
Transaction
()
...
@@ -178,7 +178,7 @@ class VersionStorage:
...
@@ -178,7 +178,7 @@ class VersionStorage:
self
.
assertRaises
(
POSException
.
VersionError
,
self
.
assertRaises
(
POSException
.
VersionError
,
self
.
_storage
.
abortVersion
,
self
.
_storage
.
abortVersion
,
''
,
t
)
''
,
t
)
# But now we really try to abort the version
# But now we really try to abort the version
oids
=
self
.
_storage
.
abortVersion
(
version
,
t
)
oids
=
self
.
_storage
.
abortVersion
(
version
,
t
)
self
.
_storage
.
tpc_vote
(
t
)
self
.
_storage
.
tpc_vote
(
t
)
...
@@ -258,7 +258,7 @@ class VersionStorage:
...
@@ -258,7 +258,7 @@ class VersionStorage:
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
data
,
revid2
=
self
.
_storage
.
load
(
oid1
,
''
)
data
,
revid2
=
self
.
_storage
.
load
(
oid1
,
''
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
# Okay, now let's commit object1 to version2
# Okay, now let's commit object1 to version2
t
=
Transaction
()
t
=
Transaction
()
self
.
_storage
.
tpc_begin
(
t
)
self
.
_storage
.
tpc_begin
(
t
)
...
@@ -274,7 +274,7 @@ class VersionStorage:
...
@@ -274,7 +274,7 @@ class VersionStorage:
eq
(
zodb_unpickle
(
data
),
MinPO
(
54
))
eq
(
zodb_unpickle
(
data
),
MinPO
(
54
))
# an object can only exist in one version, so a load from
# an object can only exist in one version, so a load from
# version1 should now give the non-version data
# version1 should now give the non-version data
data
,
revid2
=
self
.
_storage
.
load
(
oid1
,
version1
)
data
,
revid2
=
self
.
_storage
.
load
(
oid1
,
version1
)
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
eq
(
zodb_unpickle
(
data
),
MinPO
(
51
))
...
...
trunk/src/ZODB/tests/speed.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
usage
=
"""Test speed of a ZODB storage
usage
=
"""Test speed of a ZODB storage
...
@@ -34,7 +34,7 @@ Options:
...
@@ -34,7 +34,7 @@ Options:
-M Output means only
-M Output means only
"""
"""
import
sys
,
os
,
getopt
,
string
,
time
import
sys
,
os
,
getopt
,
string
,
time
sys
.
path
.
insert
(
0
,
os
.
getcwd
())
sys
.
path
.
insert
(
0
,
os
.
getcwd
())
...
@@ -114,11 +114,11 @@ def main(args):
...
@@ -114,11 +114,11 @@ def main(args):
sys
.
stderr
.
write
(
"mean:
\
t
%s
\
t
%.4f
\
t
%.4f (s/o)
\
n
"
%
(
r
,
t
,
t
/
r
))
sys
.
stderr
.
write
(
"mean:
\
t
%s
\
t
%.4f
\
t
%.4f (s/o)
\
n
"
%
(
r
,
t
,
t
/
r
))
db
.
close
()
db
.
close
()
def
compress
(
s
):
def
compress
(
s
):
c
=
zlib
.
compressobj
()
c
=
zlib
.
compressobj
()
o
=
c
.
compress
(
s
)
o
=
c
.
compress
(
s
)
return
o
+
c
.
flush
()
return
o
+
c
.
flush
()
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
1
:])
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
1
:])
trunk/src/ZODB/tests/testActivityMonitor.py
View file @
bc40c6a3
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
See ZODB/ActivityMonitor.py
See ZODB/ActivityMonitor.py
$Id: testActivityMonitor.py,v 1.
2 2002/06/10 20:20:44 shane
Exp $
$Id: testActivityMonitor.py,v 1.
3 2002/08/14 22:07:09 mj
Exp $
"""
"""
import
unittest
import
unittest
...
@@ -74,7 +74,7 @@ class Tests(unittest.TestCase):
...
@@ -74,7 +74,7 @@ class Tests(unittest.TestCase):
am
.
setHistoryLength
(
0.1
)
am
.
setHistoryLength
(
0.1
)
self
.
assertEqual
(
am
.
getHistoryLength
(),
0.1
)
self
.
assertEqual
(
am
.
getHistoryLength
(),
0.1
)
self
.
assert_
(
len
(
am
.
log
)
<=
1
)
self
.
assert_
(
len
(
am
.
log
)
<=
1
)
def
testActivityAnalysis
(
self
):
def
testActivityAnalysis
(
self
):
am
=
ActivityMonitor
(
history_length
=
3600
)
am
=
ActivityMonitor
(
history_length
=
3600
)
c
=
FakeConnection
()
c
=
FakeConnection
()
...
@@ -98,7 +98,7 @@ class Tests(unittest.TestCase):
...
@@ -98,7 +98,7 @@ class Tests(unittest.TestCase):
self
.
assert_
(
div
[
'start'
]
>
0
)
self
.
assert_
(
div
[
'start'
]
>
0
)
self
.
assert_
(
div
[
'start'
]
>=
lastend
)
self
.
assert_
(
div
[
'start'
]
>=
lastend
)
self
.
assert_
(
div
[
'start'
]
<
div
[
'end'
])
self
.
assert_
(
div
[
'start'
]
<
div
[
'end'
])
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
Tests
)
return
unittest
.
makeSuite
(
Tests
)
...
...
trunk/src/ZODB/tests/testCache.py
View file @
bc40c6a3
...
@@ -50,7 +50,7 @@ class CacheTestBase(unittest.TestCase):
...
@@ -50,7 +50,7 @@ class CacheTestBase(unittest.TestCase):
if
d
is
None
:
if
d
is
None
:
d
=
r
[
i
]
=
PersistentMapping
()
d
=
r
[
i
]
=
PersistentMapping
()
get_transaction
().
commit
()
get_transaction
().
commit
()
for
i
in
range
(
15
):
for
i
in
range
(
15
):
o
=
d
.
get
(
i
)
o
=
d
.
get
(
i
)
if
o
is
None
:
if
o
is
None
:
...
@@ -116,7 +116,7 @@ class DBMethods(CacheTestBase):
...
@@ -116,7 +116,7 @@ class DBMethods(CacheTestBase):
c
.
klass_items
()
c
.
klass_items
()
class
LRUCacheTests
(
CacheTestBase
):
class
LRUCacheTests
(
CacheTestBase
):
def
checkLRU
(
self
):
def
checkLRU
(
self
):
# verify the LRU behavior of the cache
# verify the LRU behavior of the cache
dataset_size
=
5
dataset_size
=
5
...
@@ -166,7 +166,7 @@ class LRUCacheTests(CacheTestBase):
...
@@ -166,7 +166,7 @@ class LRUCacheTests(CacheTestBase):
CONNS
=
3
CONNS
=
3
for
i
in
range
(
CONNS
):
for
i
in
range
(
CONNS
):
self
.
noodle_new_connection
()
self
.
noodle_new_connection
()
self
.
assertEquals
(
self
.
db
.
cacheSize
(),
CACHE_SIZE
*
CONNS
)
self
.
assertEquals
(
self
.
db
.
cacheSize
(),
CACHE_SIZE
*
CONNS
)
details
=
self
.
db
.
cacheDetailSize
()
details
=
self
.
db
.
cacheDetailSize
()
self
.
assertEquals
(
len
(
details
),
CONNS
)
self
.
assertEquals
(
len
(
details
),
CONNS
)
...
@@ -183,7 +183,7 @@ class LRUCacheTests(CacheTestBase):
...
@@ -183,7 +183,7 @@ class LRUCacheTests(CacheTestBase):
CONNS
=
3
CONNS
=
3
for
i
in
range
(
CONNS
):
for
i
in
range
(
CONNS
):
self
.
noodle_new_connection
()
self
.
noodle_new_connection
()
for
klass
,
count
in
self
.
db
.
cacheDetail
():
for
klass
,
count
in
self
.
db
.
cacheDetail
():
if
klass
.
endswith
(
'MinPO'
):
if
klass
.
endswith
(
'MinPO'
):
self
.
assertEqual
(
count
,
CONNS
*
CACHE_SIZE
)
self
.
assertEqual
(
count
,
CONNS
*
CACHE_SIZE
)
...
@@ -236,7 +236,7 @@ class CacheErrors(unittest.TestCase):
...
@@ -236,7 +236,7 @@ class CacheErrors(unittest.TestCase):
def
checkBogusObject
(
self
):
def
checkBogusObject
(
self
):
def
add
(
key
,
obj
):
def
add
(
key
,
obj
):
self
.
cache
[
key
]
=
obj
self
.
cache
[
key
]
=
obj
key
=
p64
(
2
)
key
=
p64
(
2
)
# value isn't persistent
# value isn't persistent
self
.
assertRaises
(
TypeError
,
add
,
key
,
12
)
self
.
assertRaises
(
TypeError
,
add
,
key
,
12
)
...
...
trunk/src/ZODB/tests/testDB.py
View file @
bc40c6a3
...
@@ -38,4 +38,3 @@ class DBTests(unittest.TestCase):
...
@@ -38,4 +38,3 @@ class DBTests(unittest.TestCase):
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
DBTests
)
return
unittest
.
makeSuite
(
DBTests
)
trunk/src/ZODB/tests/testDemoStorage.py
View file @
bc40c6a3
...
@@ -24,4 +24,3 @@ if __name__ == "__main__":
...
@@ -24,4 +24,3 @@ if __name__ == "__main__":
loader
=
unittest
.
TestLoader
()
loader
=
unittest
.
TestLoader
()
loader
.
testMethodPrefix
=
"check"
loader
.
testMethodPrefix
=
"check"
unittest
.
main
(
testLoader
=
loader
)
unittest
.
main
(
testLoader
=
loader
)
trunk/src/ZODB/tests/testFileStorage.py
View file @
bc40c6a3
...
@@ -124,7 +124,7 @@ class FileStorageRecoveryTest(
...
@@ -124,7 +124,7 @@ class FileStorageRecoveryTest(
self
.
assertRaises
(
IndexError
,
lambda
i
:
trans
[
i
],
1
)
self
.
assertRaises
(
IndexError
,
lambda
i
:
trans
[
i
],
1
)
self
.
assertEqual
(
data
.
oid
,
oid
)
self
.
assertEqual
(
data
.
oid
,
oid
)
self
.
assertEqual
(
data
.
data
,
None
)
self
.
assertEqual
(
data
.
data
,
None
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
makeSuite
(
FileStorageTests
,
'check'
)
suite
=
unittest
.
makeSuite
(
FileStorageTests
,
'check'
)
...
@@ -140,14 +140,14 @@ def main():
...
@@ -140,14 +140,14 @@ def main():
runner
.
run
(
alltests
)
runner
.
run
(
alltests
)
def
debug
():
def
debug
():
test_suite
().
debug
()
test_suite
().
debug
()
def
pdebug
():
def
pdebug
():
import
pdb
import
pdb
pdb
.
run
(
'debug()'
)
pdb
.
run
(
'debug()'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
globals
()[
sys
.
argv
[
1
]]()
globals
()[
sys
.
argv
[
1
]]()
else
:
else
:
main
()
main
()
trunk/src/ZODB/tests/testMappingStorage.py
View file @
bc40c6a3
...
@@ -22,4 +22,3 @@ if __name__ == "__main__":
...
@@ -22,4 +22,3 @@ if __name__ == "__main__":
loader
=
unittest
.
TestLoader
()
loader
=
unittest
.
TestLoader
()
loader
.
testMethodPrefix
=
"check"
loader
.
testMethodPrefix
=
"check"
unittest
.
main
(
testLoader
=
loader
)
unittest
.
main
(
testLoader
=
loader
)
trunk/src/ZODB/tests/testPersistentMapping.py
View file @
bc40c6a3
...
@@ -31,7 +31,7 @@ class PMTests(unittest.TestCase):
...
@@ -31,7 +31,7 @@ class PMTests(unittest.TestCase):
s
.
store
(
'
\
000
'
*
8
,
None
,
pickle
,
''
,
t
)
s
.
store
(
'
\
000
'
*
8
,
None
,
pickle
,
''
,
t
)
s
.
tpc_vote
(
t
)
s
.
tpc_vote
(
t
)
s
.
tpc_finish
(
t
)
s
.
tpc_finish
(
t
)
db
=
ZODB
.
DB
(
s
)
db
=
ZODB
.
DB
(
s
)
# If the root can be loaded successfully, we should be okay.
# If the root can be loaded successfully, we should be okay.
r
=
db
.
open
().
root
()
r
=
db
.
open
().
root
()
...
...
trunk/src/ZODB/tests/testTransaction.py
View file @
bc40c6a3
...
@@ -2,19 +2,19 @@
...
@@ -2,19 +2,19 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""
"""
Revision information:
Revision information:
$Id: testTransaction.py,v 1.
9 2002/08/14 15:37:08 jeremy
Exp $
$Id: testTransaction.py,v 1.
10 2002/08/14 22:07:09 mj
Exp $
"""
"""
"""
"""
...
@@ -41,7 +41,7 @@ TODO
...
@@ -41,7 +41,7 @@ TODO
add in tests for objects which are modified multiple times,
add in tests for objects which are modified multiple times,
for example an object that gets modified in multiple sub txns.
for example an object that gets modified in multiple sub txns.
"""
"""
import
random
import
random
...
@@ -61,9 +61,9 @@ class TransactionTests(unittest.TestCase):
...
@@ -61,9 +61,9 @@ class TransactionTests(unittest.TestCase):
self
.
nosub1
=
DataObject
(
nost
=
1
)
self
.
nosub1
=
DataObject
(
nost
=
1
)
def
tearDown
(
self
):
def
tearDown
(
self
):
Transaction
.
free_transaction
()
Transaction
.
free_transaction
()
# basic tests with two sub trans jars
# basic tests with two sub trans jars
# really we only need one, so tests for
# really we only need one, so tests for
# sub1 should identical to tests for sub2
# sub1 should identical to tests for sub2
...
@@ -84,7 +84,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -84,7 +84,7 @@ class TransactionTests(unittest.TestCase):
get_transaction
().
abort
()
get_transaction
().
abort
()
assert
self
.
sub2
.
_p_jar
.
cabort
==
1
assert
self
.
sub2
.
_p_jar
.
cabort
==
1
def
testSubTransactionCommitCommit
(
self
):
def
testSubTransactionCommitCommit
(
self
):
...
@@ -92,10 +92,10 @@ class TransactionTests(unittest.TestCase):
...
@@ -92,10 +92,10 @@ class TransactionTests(unittest.TestCase):
self
.
sub2
.
modify
()
self
.
sub2
.
modify
()
get_transaction
().
commit
(
1
)
get_transaction
().
commit
(
1
)
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
==
1
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
==
1
get_transaction
().
commit
()
get_transaction
().
commit
()
assert
self
.
sub1
.
_p_jar
.
ccommit_sub
==
1
assert
self
.
sub1
.
_p_jar
.
ccommit_sub
==
1
...
@@ -108,13 +108,13 @@ class TransactionTests(unittest.TestCase):
...
@@ -108,13 +108,13 @@ class TransactionTests(unittest.TestCase):
get_transaction
().
commit
(
1
)
get_transaction
().
commit
(
1
)
get_transaction
().
abort
()
get_transaction
().
abort
()
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
cabort
==
0
assert
self
.
sub1
.
_p_jar
.
cabort
==
0
assert
self
.
sub1
.
_p_jar
.
cabort_sub
==
1
assert
self
.
sub1
.
_p_jar
.
cabort_sub
==
1
def
testMultipleSubTransactionCommitCommit
(
self
):
def
testMultipleSubTransactionCommitCommit
(
self
):
# add it
# add it
self
.
sub1
.
modify
()
self
.
sub1
.
modify
()
...
@@ -133,7 +133,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -133,7 +133,7 @@ class TransactionTests(unittest.TestCase):
# objects... i don't like this but its an impl artifact
# objects... i don't like this but its an impl artifact
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
0
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
0
# add another before we do the entire txn commit
# add another before we do the entire txn commit
self
.
sub3
.
modify
()
self
.
sub3
.
modify
()
...
@@ -160,7 +160,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -160,7 +160,7 @@ class TransactionTests(unittest.TestCase):
sub1 calling method tpc_finish
sub1 calling method tpc_finish
sub2 calling method tpc_finish
sub2 calling method tpc_finish
"""
"""
# add it
# add it
self
.
sub1
.
modify
()
self
.
sub1
.
modify
()
...
@@ -172,7 +172,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -172,7 +172,7 @@ class TransactionTests(unittest.TestCase):
get_transaction
().
commit
(
1
)
get_transaction
().
commit
(
1
)
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
0
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
0
# add another before we do the entire txn commit
# add another before we do the entire txn commit
self
.
sub3
.
modify
()
self
.
sub3
.
modify
()
...
@@ -185,7 +185,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -185,7 +185,7 @@ class TransactionTests(unittest.TestCase):
assert
self
.
sub3
.
_p_jar
.
cabort
==
1
assert
self
.
sub3
.
_p_jar
.
cabort
==
1
assert
self
.
sub1
.
_p_jar
.
ccommit_sub
==
1
assert
self
.
sub1
.
_p_jar
.
ccommit_sub
==
1
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
1
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
1
# repeat adding in a nonsub trans jars
# repeat adding in a nonsub trans jars
...
@@ -213,7 +213,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -213,7 +213,7 @@ class TransactionTests(unittest.TestCase):
the nosub jar should not have tpc_finish
the nosub jar should not have tpc_finish
called on it till the containing txn
called on it till the containing txn
ends.
ends.
sub calling method commit
sub calling method commit
nosub calling method tpc_begin
nosub calling method tpc_begin
sub calling method tpc_finish
sub calling method tpc_finish
...
@@ -221,7 +221,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -221,7 +221,7 @@ class TransactionTests(unittest.TestCase):
nosub calling method abort
nosub calling method abort
sub calling method abort_sub
sub calling method abort_sub
"""
"""
self
.
sub1
.
modify
(
tracing
=
'sub'
)
self
.
sub1
.
modify
(
tracing
=
'sub'
)
self
.
nosub1
.
modify
(
tracing
=
'nosub'
)
self
.
nosub1
.
modify
(
tracing
=
'nosub'
)
...
@@ -276,10 +276,10 @@ class TransactionTests(unittest.TestCase):
...
@@ -276,10 +276,10 @@ class TransactionTests(unittest.TestCase):
nosub calling method tpc_finish
nosub calling method tpc_finish
sub1 calling method tpc_finish
sub1 calling method tpc_finish
"""
"""
# add it
# add it
self
.
sub1
.
modify
()
self
.
sub1
.
modify
()
get_transaction
().
commit
(
1
)
get_transaction
().
commit
(
1
)
# add another
# add another
...
@@ -288,15 +288,15 @@ class TransactionTests(unittest.TestCase):
...
@@ -288,15 +288,15 @@ class TransactionTests(unittest.TestCase):
get_transaction
().
commit
(
1
)
get_transaction
().
commit
(
1
)
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
nosub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
nosub1
.
_p_jar
.
ctpc_vote
==
0
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
0
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
0
# add another before we do the entire txn commit
# add another before we do the entire txn commit
self
.
sub2
.
modify
()
self
.
sub2
.
modify
()
# commit the container transaction
# commit the container transaction
get_transaction
().
commit
()
get_transaction
().
commit
()
# we did an implicit sub commit
# we did an implicit sub commit
assert
self
.
sub2
.
_p_jar
.
ccommit_sub
==
1
assert
self
.
sub2
.
_p_jar
.
ccommit_sub
==
1
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
1
assert
self
.
sub1
.
_p_jar
.
ctpc_finish
>
1
...
@@ -308,28 +308,28 @@ class TransactionTests(unittest.TestCase):
...
@@ -308,28 +308,28 @@ class TransactionTests(unittest.TestCase):
# error handling by throwing errors from
# error handling by throwing errors from
# various jar methods
# various jar methods
###
###
# first the recoverable errors
# first the recoverable errors
def
testExceptionInAbort
(
self
):
def
testExceptionInAbort
(
self
):
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'abort'
)
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'abort'
)
self
.
nosub1
.
modify
()
self
.
nosub1
.
modify
()
self
.
sub1
.
modify
(
nojar
=
1
)
self
.
sub1
.
modify
(
nojar
=
1
)
self
.
sub2
.
modify
()
self
.
sub2
.
modify
()
try
:
try
:
get_transaction
().
abort
()
get_transaction
().
abort
()
except
TestTxnException
:
pass
except
TestTxnException
:
pass
assert
self
.
nosub1
.
_p_jar
.
cabort
==
1
assert
self
.
nosub1
.
_p_jar
.
cabort
==
1
assert
self
.
sub2
.
_p_jar
.
cabort
==
1
assert
self
.
sub2
.
_p_jar
.
cabort
==
1
def
testExceptionInCommit
(
self
):
def
testExceptionInCommit
(
self
):
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'commit'
)
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'commit'
)
self
.
nosub1
.
modify
()
self
.
nosub1
.
modify
()
self
.
sub1
.
modify
(
nojar
=
1
)
self
.
sub1
.
modify
(
nojar
=
1
)
...
@@ -345,14 +345,14 @@ class TransactionTests(unittest.TestCase):
...
@@ -345,14 +345,14 @@ class TransactionTests(unittest.TestCase):
def
testExceptionInTpcVote
(
self
):
def
testExceptionInTpcVote
(
self
):
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'tpc_vote'
)
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'tpc_vote'
)
self
.
nosub1
.
modify
()
self
.
nosub1
.
modify
()
self
.
sub1
.
modify
(
nojar
=
1
)
self
.
sub1
.
modify
(
nojar
=
1
)
try
:
try
:
get_transaction
().
commit
()
get_transaction
().
commit
()
except
TestTxnException
:
pass
except
TestTxnException
:
pass
assert
self
.
nosub1
.
_p_jar
.
ctpc_finish
==
0
assert
self
.
nosub1
.
_p_jar
.
ctpc_finish
==
0
assert
self
.
nosub1
.
_p_jar
.
ccommit
==
1
assert
self
.
nosub1
.
_p_jar
.
ccommit
==
1
assert
self
.
nosub1
.
_p_jar
.
ctpc_abort
==
1
assert
self
.
nosub1
.
_p_jar
.
ctpc_abort
==
1
...
@@ -363,7 +363,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -363,7 +363,7 @@ class TransactionTests(unittest.TestCase):
"""
"""
ok this test reveals a bug in the TM.py
ok this test reveals a bug in the TM.py
as the nosub tpc_abort there is ignored.
as the nosub tpc_abort there is ignored.
nosub calling method tpc_begin
nosub calling method tpc_begin
nosub calling method commit
nosub calling method commit
sub calling method tpc_begin
sub calling method tpc_begin
...
@@ -372,11 +372,11 @@ class TransactionTests(unittest.TestCase):
...
@@ -372,11 +372,11 @@ class TransactionTests(unittest.TestCase):
nosub calling method tpc_abort
nosub calling method tpc_abort
"""
"""
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'tpc_begin'
)
self
.
sub1
.
_p_jar
=
SubTransactionJar
(
errors
=
'tpc_begin'
)
self
.
nosub1
.
modify
()
self
.
nosub1
.
modify
()
self
.
sub1
.
modify
(
nojar
=
1
)
self
.
sub1
.
modify
(
nojar
=
1
)
try
:
try
:
get_transaction
().
commit
()
get_transaction
().
commit
()
except
TestTxnException
:
pass
except
TestTxnException
:
pass
...
@@ -401,7 +401,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -401,7 +401,7 @@ class TransactionTests(unittest.TestCase):
### More Failure modes...
### More Failure modes...
# now we mix in some sub transactions
# now we mix in some sub transactions
###
###
def
testExceptionInSubCommitSub
(
self
):
def
testExceptionInSubCommitSub
(
self
):
"""
"""
this tests exhibits some odd behavior,
this tests exhibits some odd behavior,
...
@@ -433,19 +433,19 @@ class TransactionTests(unittest.TestCase):
...
@@ -433,19 +433,19 @@ class TransactionTests(unittest.TestCase):
try
:
try
:
get_transaction
().
commit
()
get_transaction
().
commit
()
except
TestTxnException
:
pass
except
TestTxnException
:
pass
# odd this doesn't seem to be entirely deterministic..
# odd this doesn't seem to be entirely deterministic..
if
self
.
sub1
.
_p_jar
.
ccommit_sub
:
if
self
.
sub1
.
_p_jar
.
ccommit_sub
:
assert
self
.
sub1
.
_p_jar
.
ctpc_abort
==
1
assert
self
.
sub1
.
_p_jar
.
ctpc_abort
==
1
else
:
else
:
assert
self
.
sub1
.
_p_jar
.
cabort_sub
==
1
assert
self
.
sub1
.
_p_jar
.
cabort_sub
==
1
if
self
.
sub3
.
_p_jar
.
ccommit_sub
:
if
self
.
sub3
.
_p_jar
.
ccommit_sub
:
assert
self
.
sub3
.
_p_jar
.
ctpc_abort
==
1
assert
self
.
sub3
.
_p_jar
.
ctpc_abort
==
1
else
:
else
:
assert
self
.
sub3
.
_p_jar
.
cabort_sub
==
1
assert
self
.
sub3
.
_p_jar
.
cabort_sub
==
1
assert
self
.
sub2
.
_p_jar
.
ctpc_abort
==
1
assert
self
.
sub2
.
_p_jar
.
ctpc_abort
==
1
assert
self
.
nosub1
.
_p_jar
.
ctpc_abort
==
1
assert
self
.
nosub1
.
_p_jar
.
ctpc_abort
==
1
...
@@ -458,7 +458,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -458,7 +458,7 @@ class TransactionTests(unittest.TestCase):
self
.
sub2
.
_p_jar
=
SubTransactionJar
(
errors
=
'abort_sub'
)
self
.
sub2
.
_p_jar
=
SubTransactionJar
(
errors
=
'abort_sub'
)
self
.
sub2
.
modify
(
nojar
=
1
)
self
.
sub2
.
modify
(
nojar
=
1
)
get_transaction
().
commit
(
1
)
get_transaction
().
commit
(
1
)
self
.
sub3
.
modify
()
self
.
sub3
.
modify
()
try
:
try
:
...
@@ -516,7 +516,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -516,7 +516,7 @@ class TransactionTests(unittest.TestCase):
succeed
+=
1
succeed
+=
1
elif
jar
.
ctpc_abort
:
elif
jar
.
ctpc_abort
:
fail
+=
1
fail
+=
1
if
Transaction
.
hosed
:
if
Transaction
.
hosed
:
self
.
assert_
(
fail
>
0
and
succeed
>
0
)
self
.
assert_
(
fail
>
0
and
succeed
>
0
)
break
break
...
@@ -526,7 +526,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -526,7 +526,7 @@ class TransactionTests(unittest.TestCase):
self
.
setUp
()
self
.
setUp
()
else
:
else
:
self
.
fail
(
"Couldn't provoke hosed state."
)
self
.
fail
(
"Couldn't provoke hosed state."
)
self
.
sub2
.
modify
()
self
.
sub2
.
modify
()
try
:
try
:
...
@@ -566,22 +566,22 @@ class BasicJar:
...
@@ -566,22 +566,22 @@ class BasicJar:
self
.
ctpc_vote
=
0
self
.
ctpc_vote
=
0
self
.
ctpc_finish
=
0
self
.
ctpc_finish
=
0
self
.
cabort_sub
=
0
self
.
cabort_sub
=
0
self
.
ccommit_sub
=
0
self
.
ccommit_sub
=
0
def
check
(
self
,
method
):
def
check
(
self
,
method
):
if
self
.
tracing
:
if
self
.
tracing
:
print
'%s calling method %s'
%
(
str
(
self
.
tracing
),
method
)
print
'%s calling method %s'
%
(
str
(
self
.
tracing
),
method
)
if
((
type
(
self
.
errors
)
is
TupleType
and
method
in
self
.
errors
)
if
((
type
(
self
.
errors
)
is
TupleType
and
method
in
self
.
errors
)
or
method
==
self
.
errors
):
or
method
==
self
.
errors
):
raise
TestTxnException
(
"error %s"
%
method
)
raise
TestTxnException
(
"error %s"
%
method
)
## basic jar txn interface
## basic jar txn interface
def
abort
(
self
,
*
args
):
def
abort
(
self
,
*
args
):
self
.
check
(
'abort'
)
self
.
check
(
'abort'
)
self
.
cabort
+=
1
self
.
cabort
+=
1
def
commit
(
self
,
*
args
):
def
commit
(
self
,
*
args
):
self
.
check
(
'commit'
)
self
.
check
(
'commit'
)
self
.
ccommit
+=
1
self
.
ccommit
+=
1
...
@@ -607,11 +607,11 @@ class SubTransactionJar(BasicJar):
...
@@ -607,11 +607,11 @@ class SubTransactionJar(BasicJar):
def
abort_sub
(
self
,
txn
):
def
abort_sub
(
self
,
txn
):
self
.
check
(
'abort_sub'
)
self
.
check
(
'abort_sub'
)
self
.
cabort_sub
=
1
self
.
cabort_sub
=
1
def
commit_sub
(
self
,
txn
):
def
commit_sub
(
self
,
txn
):
self
.
check
(
'commit_sub'
)
self
.
check
(
'commit_sub'
)
self
.
ccommit_sub
=
1
self
.
ccommit_sub
=
1
class
NoSubTransactionJar
(
BasicJar
):
pass
class
NoSubTransactionJar
(
BasicJar
):
pass
def
test_suite
():
def
test_suite
():
...
...
trunk/src/ZODB/tests/testUtils.py
View file @
bc40c6a3
...
@@ -14,7 +14,7 @@ class TestUtils(unittest.TestCase):
...
@@ -14,7 +14,7 @@ class TestUtils(unittest.TestCase):
large
=
[
random
.
randrange
(
1L
<<
32
,
1L
<<
64
,
int
=
long
)
large
=
[
random
.
randrange
(
1L
<<
32
,
1L
<<
64
,
int
=
long
)
for
i
in
range
(
NUM
)]
for
i
in
range
(
NUM
)]
all
=
small
+
large
all
=
small
+
large
def
checkLongToStringToLong
(
self
):
def
checkLongToStringToLong
(
self
):
for
num
in
self
.
all
:
for
num
in
self
.
all
:
s
=
p64
(
num
)
s
=
p64
(
num
)
...
@@ -33,9 +33,8 @@ class TestUtils(unittest.TestCase):
...
@@ -33,9 +33,8 @@ class TestUtils(unittest.TestCase):
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
TestUtils
,
'check'
)
return
unittest
.
makeSuite
(
TestUtils
,
'check'
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
loader
=
unittest
.
TestLoader
()
loader
=
unittest
.
TestLoader
()
loader
.
testMethodPrefix
=
"check"
loader
.
testMethodPrefix
=
"check"
unittest
.
main
(
testLoader
=
loader
)
unittest
.
main
(
testLoader
=
loader
)
trunk/src/ZODB/tests/testZODB.py
View file @
bc40c6a3
...
@@ -72,7 +72,7 @@ class ExportImportTests:
...
@@ -72,7 +72,7 @@ class ExportImportTests:
def
checkDuplicateAborted
(
self
):
def
checkDuplicateAborted
(
self
):
self
.
checkDuplicate
(
abort_it
=
1
,
dup_name
=
'test_duplicate_aborted'
)
self
.
checkDuplicate
(
abort_it
=
1
,
dup_name
=
'test_duplicate_aborted'
)
class
ZODBTests
(
unittest
.
TestCase
,
ExportImportTests
):
class
ZODBTests
(
unittest
.
TestCase
,
ExportImportTests
):
...
@@ -103,14 +103,14 @@ def main():
...
@@ -103,14 +103,14 @@ def main():
runner
.
run
(
alltests
)
runner
.
run
(
alltests
)
def
debug
():
def
debug
():
test_suite
().
debug
()
test_suite
().
debug
()
def
pdebug
():
def
pdebug
():
import
pdb
import
pdb
pdb
.
run
(
'debug()'
)
pdb
.
run
(
'debug()'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
globals
()[
sys
.
argv
[
1
]]()
globals
()[
sys
.
argv
[
1
]]()
else
:
else
:
main
()
main
()
trunk/src/ZODB/tests/testfsIndex.py
View file @
bc40c6a3
import
unittest
,
sys
import
unittest
,
sys
from
ZODB.fsIndex
import
fsIndex
from
ZODB.fsIndex
import
fsIndex
from
ZODB.utils
import
p64
from
ZODB.utils
import
p64
...
@@ -14,7 +13,7 @@ class Test(unittest.TestCase):
...
@@ -14,7 +13,7 @@ class Test(unittest.TestCase):
for
i
in
range
(
0
,
200
):
for
i
in
range
(
0
,
200
):
self
.
assertEqual
((
i
,
index
[
p64
(
i
*
1000
)]),
(
i
,(
i
*
1000L
+
1
)))
self
.
assertEqual
((
i
,
index
[
p64
(
i
*
1000
)]),
(
i
,(
i
*
1000L
+
1
)))
self
.
assertEqual
(
len
(
index
),
200
)
self
.
assertEqual
(
len
(
index
),
200
)
key
=
p64
(
2000
)
key
=
p64
(
2000
)
...
@@ -38,12 +37,12 @@ class Test(unittest.TestCase):
...
@@ -38,12 +37,12 @@ class Test(unittest.TestCase):
for
i
in
range
(
400
,
600
):
for
i
in
range
(
400
,
600
):
d
[
p64
(
i
*
1000
)]
=
(
i
*
1000L
+
1
)
d
[
p64
(
i
*
1000
)]
=
(
i
*
1000L
+
1
)
index
.
update
(
d
)
index
.
update
(
d
)
for
i
in
range
(
100
,
500
):
for
i
in
range
(
100
,
500
):
d
[
p64
(
i
*
1000
)]
=
(
i
*
1000L
+
2
)
d
[
p64
(
i
*
1000
)]
=
(
i
*
1000L
+
2
)
index
.
update
(
d
)
index
.
update
(
d
)
self
.
assertEqual
(
index
.
get
(
p64
(
2000
)),
2001
)
self
.
assertEqual
(
index
.
get
(
p64
(
2000
)),
2001
)
...
...
trunk/src/ZODB/utils.py
View file @
bc40c6a3
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
import
sys
import
sys
...
@@ -64,7 +64,7 @@ def cp(f1, f2, l):
...
@@ -64,7 +64,7 @@ def cp(f1, f2, l):
read
=
f1
.
read
read
=
f1
.
read
write
=
f2
.
write
write
=
f2
.
write
n
=
8192
n
=
8192
while
l
>
0
:
while
l
>
0
:
if
n
>
l
:
if
n
>
l
:
n
=
l
n
=
l
...
...
trunk/src/persistent/list.py
View file @
bc40c6a3
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python implementation of persistent list.
"""Python implementation of persistent list.
$Id: list.py,v 1.
2 2002/02/11 23:49:07 gvanrossum
Exp $"""
$Id: list.py,v 1.
3 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
from
UserList
import
UserList
from
UserList
import
UserList
...
@@ -51,7 +51,7 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -51,7 +51,7 @@ class PersistentList(UserList, Persistence.Persistent):
def
__delslice__
(
self
,
i
,
j
):
def
__delslice__
(
self
,
i
,
j
):
self
.
__super_delslice
(
i
,
j
)
self
.
__super_delslice
(
i
,
j
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
__iadd__
(
self
,
other
):
def
__iadd__
(
self
,
other
):
self
.
__super_iadd
(
other
)
self
.
__super_iadd
(
other
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
@@ -63,7 +63,7 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -63,7 +63,7 @@ class PersistentList(UserList, Persistence.Persistent):
def
append
(
self
,
item
):
def
append
(
self
,
item
):
self
.
__super_append
(
item
)
self
.
__super_append
(
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
insert
(
self
,
i
,
item
):
def
insert
(
self
,
i
,
item
):
self
.
__super_insert
(
i
,
item
)
self
.
__super_insert
(
i
,
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
@@ -76,11 +76,11 @@ class PersistentList(UserList, Persistence.Persistent):
...
@@ -76,11 +76,11 @@ class PersistentList(UserList, Persistence.Persistent):
def
remove
(
self
,
item
):
def
remove
(
self
,
item
):
self
.
__super_remove
(
item
)
self
.
__super_remove
(
item
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
reverse
(
self
):
def
reverse
(
self
):
self
.
__super_reverse
()
self
.
__super_reverse
()
self
.
_p_changed
=
1
self
.
_p_changed
=
1
def
sort
(
self
,
*
args
):
def
sort
(
self
,
*
args
):
self
.
__super_sort
(
*
args
)
self
.
__super_sort
(
*
args
)
self
.
_p_changed
=
1
self
.
_p_changed
=
1
...
...
trunk/src/persistent/mapping.py
View file @
bc40c6a3
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# All Rights Reserved.
#
#
# This software is subject to the provisions of the Zope Public License,
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
"""Python implementation of persistent base types
"""Python implementation of persistent base types
$Id: mapping.py,v 1.
19 2002/02/12 22:33:08 gvanrossum
Exp $"""
$Id: mapping.py,v 1.
20 2002/08/14 22:07:09 mj
Exp $"""
__version__
=
'$Revision: 1.
19
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
20
$'
[
11
:
-
2
]
import
Persistence
import
Persistence
from
UserDict
import
UserDict
from
UserDict
import
UserDict
...
@@ -82,7 +82,7 @@ class PersistentMapping(UserDict, Persistence.Persistent):
...
@@ -82,7 +82,7 @@ class PersistentMapping(UserDict, Persistence.Persistent):
# different versions of the code. Compatibility works in both
# different versions of the code. Compatibility works in both
# directions, because an application may want to share a database
# directions, because an application may want to share a database
# between applications using different versions of the code.
# between applications using different versions of the code.
# Effectively, the original rep is part of the "API." To provide
# Effectively, the original rep is part of the "API." To provide
# full compatibility, the getstate and setstate must read and
# full compatibility, the getstate and setstate must read and
# right objects using the old rep.
# right objects using the old rep.
...
...
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