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
nexedi
ZODB
Commits
fc049e1f
Commit
fc049e1f
authored
Apr 19, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Whitespace normalization.
parent
c0914442
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
118 additions
and
125 deletions
+118
-125
src/Persistence/tests/test_ExtensionClass.py
src/Persistence/tests/test_ExtensionClass.py
+1
-2
src/ThreadedAsync/LoopCallback.py
src/ThreadedAsync/LoopCallback.py
+2
-2
src/ZEO/tests/ConnectionTests.py
src/ZEO/tests/ConnectionTests.py
+1
-1
src/ZODB/BaseStorage.py
src/ZODB/BaseStorage.py
+3
-3
src/ZODB/DB.py
src/ZODB/DB.py
+2
-2
src/ZODB/FileStorage/fspack.py
src/ZODB/FileStorage/fspack.py
+0
-1
src/ZODB/MappingStorage.py
src/ZODB/MappingStorage.py
+2
-2
src/ZODB/broken.py
src/ZODB/broken.py
+5
-5
src/ZODB/interfaces.py
src/ZODB/interfaces.py
+2
-2
src/ZODB/serialize.py
src/ZODB/serialize.py
+2
-2
src/ZODB/tests/PackableStorage.py
src/ZODB/tests/PackableStorage.py
+3
-3
src/ZODB/tests/sampledm.py
src/ZODB/tests/sampledm.py
+9
-9
src/ZODB/tests/testBroken.py
src/ZODB/tests/testBroken.py
+3
-3
src/ZODB/tests/testCache.py
src/ZODB/tests/testCache.py
+4
-4
src/ZODB/tests/test_cache.py
src/ZODB/tests/test_cache.py
+7
-7
src/ZODB/tests/util.py
src/ZODB/tests/util.py
+2
-2
src/ZODB/tests/warnhook.py
src/ZODB/tests/warnhook.py
+0
-1
src/ZODB/zodb4/conversion.py
src/ZODB/zodb4/conversion.py
+2
-2
src/ZODB/zodb4/main.py
src/ZODB/zodb4/main.py
+1
-1
src/ZODB/zodb4/z4errors.py
src/ZODB/zodb4/z4errors.py
+0
-1
src/ZODB/zodb4/z4interfaces.py
src/ZODB/zodb4/z4interfaces.py
+3
-3
src/persistent/interfaces.py
src/persistent/interfaces.py
+4
-4
src/persistent/tests/persistenttestbase.py
src/persistent/tests/persistenttestbase.py
+1
-2
src/persistent/tests/test_overriding_attrs.py
src/persistent/tests/test_overriding_attrs.py
+20
-20
src/persistent/tests/test_pickle.py
src/persistent/tests/test_pickle.py
+3
-3
src/persistent/wref.py
src/persistent/wref.py
+19
-20
src/transaction/_manager.py
src/transaction/_manager.py
+0
-1
src/transaction/interfaces.py
src/transaction/interfaces.py
+5
-5
src/transaction/tests/test_SampleDataManager.py
src/transaction/tests/test_SampleDataManager.py
+9
-9
src/transaction/util.py
src/transaction/util.py
+2
-2
test.py
test.py
+1
-1
No files found.
src/Persistence/tests/test_ExtensionClass.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Test ExtensionClass support in Persistence.Persistent
$Id: test_ExtensionClass.py,v 1.
6 2004/02/20 17:19:43 jeremy
Exp $
$Id: test_ExtensionClass.py,v 1.
7 2004/04/19 21:19:03 tim_one
Exp $
"""
from
doctest
import
DocTestSuite
...
...
@@ -505,4 +505,3 @@ def test_pickling_w_slots_w_empty_dict():
def
test_suite
():
return
DocTestSuite
()
src/ThreadedAsync/LoopCallback.py
View file @
fc049e1f
...
...
@@ -25,7 +25,7 @@ register_loop_callback() to register interest. When the mainloop
thread calls loop(), each registered callback will be called with the
socket map as its first argument.
"""
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
import
asyncore
import
select
...
...
@@ -168,7 +168,7 @@ def loop(timeout=30.0, use_poll=0, map=None):
while
map
and
exit_status
is
None
:
poll_fun
(
timeout
,
map
)
_stop_loop
()
# This module used to do something evil -- it rebound asyncore.loop to the
# above loop() function. What was evil about this is that if you added some
...
...
src/ZEO/tests/ConnectionTests.py
View file @
fc049e1f
...
...
@@ -613,7 +613,7 @@ class InvqTests(CommonSetupTearDown):
self
.
assertEqual
(
perstorage
.
verify_result
,
"quick verification"
)
self
.
assertEqual
(
perstorage
.
_server
.
_last_invals
,
(
revid
,
[(
oid
,
''
)]))
self
.
assertEqual
(
perstorage
.
load
(
oid
,
''
),
self
.
_storage
.
load
(
oid
,
''
))
perstorage
.
close
()
...
...
src/ZODB/BaseStorage.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Handy standard storage machinery
$Id: BaseStorage.py,v 1.4
8 2004/04/17 22:19:30 gintautasm
Exp $
$Id: BaseStorage.py,v 1.4
9 2004/04/19 21:19:05 tim_one
Exp $
"""
import
cPickle
import
threading
...
...
@@ -77,7 +77,7 @@ class BaseStorage(UndoLogCompatible):
The other lock appears to protect _oid and _transaction and
perhaps other things. It is always held when load() is called, so
presumably the load() implementation should also acquire the lock.
"""
"""
_transaction
=
None
# Transaction that is being committed
_tstatus
=
' '
# Transaction status, used for copying data
_is_read_only
=
False
...
...
@@ -400,7 +400,7 @@ class BaseStorage(UndoLogCompatible):
self
.
tpc_begin
(
transaction
,
tid
,
transaction
.
status
)
for
r
in
transaction
:
oid
=
r
.
oid
if
verbose
:
if
verbose
:
print
utils
.
oid_repr
(
oid
),
r
.
version
,
len
(
r
.
data
)
if
restoring
:
self
.
restore
(
oid
,
r
.
tid
,
r
.
data
,
r
.
version
,
...
...
src/ZODB/DB.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Database objects
$Id: DB.py,v 1.7
6 2004/04/17 23:04:52 gintautasm
Exp $"""
$Id: DB.py,v 1.7
7 2004/04/19 21:19:05 tim_one
Exp $"""
import
cPickle
,
cStringIO
,
sys
from
thread
import
allocate_lock
...
...
@@ -427,7 +427,7 @@ class DB(object):
used the default transaction manager.
- `synch`: boolean indicating whether Connection should
register for afterCompletion() calls.
"""
self
.
_a
()
try
:
...
...
src/ZODB/FileStorage/fspack.py
View file @
fc049e1f
...
...
@@ -687,4 +687,3 @@ class FileStoragePacker(FileStorageFormatter):
if
self
.
_lock_counter
%
20
==
0
:
self
.
_commit_lock_acquire
()
return
ipos
src/ZODB/MappingStorage.py
View file @
fc049e1f
...
...
@@ -21,7 +21,7 @@ It is meant to illustrate the simplest possible storage.
The Mapping storage uses a single data structure to map object ids to data.
"""
__version__
=
'$Revision: 1.1
3
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
4
$'
[
11
:
-
2
]
from
ZODB
import
utils
from
ZODB
import
BaseStorage
...
...
@@ -76,7 +76,7 @@ class MappingStorage(BaseStorage.BaseStorage):
return
s
[:
8
]
finally
:
self
.
_lock_release
()
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
if
transaction
is
not
self
.
_transaction
:
...
...
src/ZODB/broken.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Broken object support
$Id: broken.py,v 1.
3 2004/03/04 22:41:52 jim
Exp $
$Id: broken.py,v 1.
4 2004/04/19 21:19:05 tim_one
Exp $
"""
import
sys
...
...
@@ -115,7 +115,7 @@ class Broken(object):
def
__setstate__
(
self
,
state
):
self
.
__dict__
[
'__Broken_state__'
]
=
state
def
__repr__
(
self
):
return
"<broken %s.%s instance>"
%
(
self
.
__class__
.
__module__
,
self
.
__class__
.
__name__
)
...
...
@@ -233,7 +233,7 @@ def rebuild(modulename, globalname, *args):
"""
class_
=
find_global
(
modulename
,
globalname
)
return
class_
.
__new__
(
class_
,
*
args
)
class
BrokenModified
(
TypeError
):
"""Attempt to modify a broken object
"""
...
...
@@ -256,7 +256,7 @@ class PersistentBroken(Broken, persistent.Persistent):
>>> persistentBroken(Atall) is PAtall
True
)
Persistent broken classes work a lot like broken classes::
...
...
@@ -315,7 +315,7 @@ class PersistentBroken(Broken, persistent.Persistent):
persistent
.
Persistent
.
__setattr__
(
self
,
name
,
value
)
else
:
raise
BrokenModified
(
"Can't change broken objects"
)
def
__repr__
(
self
):
return
"<persistent broken %s.%s instance %r>"
%
(
self
.
__class__
.
__module__
,
self
.
__class__
.
__name__
,
...
...
src/ZODB/interfaces.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Interfaces for ZODB.
$Id: interfaces.py,v 1.
3 2004/02/24 13:51:03 srichter
Exp $
$Id: interfaces.py,v 1.
4 2004/04/19 21:19:05 tim_one
Exp $
"""
try
:
...
...
@@ -88,7 +88,7 @@ class IDataManager(Interface):
flag set to false.
"""
def
tpc_abort
(
transaction
):
"""Abort a transaction.
...
...
src/ZODB/serialize.py
View file @
fc049e1f
...
...
@@ -269,7 +269,7 @@ class BaseObjectWriter:
# It's possible that __getnewargs__ is degenerate and
# returns (), but we don't want to have to deghostify
# the object to find out.
return
oid
return
oid
return
oid
,
klass
...
...
@@ -527,7 +527,7 @@ def referencesf(p, rootl=None):
# tuples, so that we wrap oids that are lists or tuples in
# tuples.
#
# - oids may *not* be False. I'm not sure why.
# - oids may *not* be False. I'm not sure why.
out
=
[]
for
v
in
rootl
:
...
...
src/ZODB/tests/PackableStorage.py
View file @
fc049e1f
...
...
@@ -281,9 +281,9 @@ class PackableStorage(PackableStorageBase):
packt
=
time
.
time
()
for
dummy
in
choices
:
for
i
in
choices
:
root
[
i
].
value
=
MinPO
(
i
)
transaction
.
commit
()
for
i
in
choices
:
root
[
i
].
value
=
MinPO
(
i
)
transaction
.
commit
()
NUM_LOOP_TRIP
=
100
timer
=
ElapsedTimer
(
time
.
time
())
...
...
src/ZODB/tests/sampledm.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Sample objects for use in tests
$Id: sampledm.py,v 1.
2 2004/02/19 02:59:10 jeremy
Exp $
$Id: sampledm.py,v 1.
3 2004/04/19 21:19:07 tim_one
Exp $
"""
class
DataManager
(
object
):
...
...
@@ -78,7 +78,7 @@ class DataManager(object):
>>> dm.commit(t1)
Our changes are"permanent". The state reflects the changes and the
delta has been reset to 0.
delta has been reset to 0.
>>> dm.state
1
...
...
@@ -139,7 +139,7 @@ class DataManager(object):
TypeError: ('Transaction missmatch', '2', '1')
>>> dm.prepare(t1)
"""
if
self
.
prepared
:
raise
TypeError
(
'Already prepared'
)
...
...
@@ -183,7 +183,7 @@ class DataManager(object):
If savepoints are used, abort must be passed the same
transaction:
>>> dm.inc()
>>> r = dm.savepoint(t1)
>>> t2 = '2'
...
...
@@ -208,15 +208,15 @@ class DataManager(object):
Of course, the transactions passed to prepare and abort must
match:
>>> dm.prepare(t1)
>>> dm.abort(t2)
Traceback (most recent call last):
...
TypeError: ('Transaction missmatch', '2', '1')
>>> dm.abort(t1)
"""
self
.
_checkTransaction
(
transaction
)
...
...
@@ -262,7 +262,7 @@ class DataManager(object):
If course, the transactions given to prepare and commit must
be the same:
>>> dm.inc()
>>> t3 = '3'
>>> dm.prepare(t3)
...
...
@@ -270,7 +270,7 @@ class DataManager(object):
Traceback (most recent call last):
...
TypeError: ('Transaction missmatch', '2', '3')
"""
if
not
self
.
prepared
:
raise
TypeError
(
'Not prepared to commit'
)
...
...
src/ZODB/tests/testBroken.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Test broken-object suppport
$Id: testBroken.py,v 1.
4 2004/04/16 15:58:11 jeremy
Exp $
$Id: testBroken.py,v 1.
5 2004/04/19 21:19:07 tim_one
Exp $
"""
import
sys
...
...
@@ -29,7 +29,7 @@ def test_integration():
>>> db = DB()
We'll create a fake module with a class:
>>> class NotThere:
... Atall = type('Atall', (persistent.Persistent, ),
... {'__module__': 'ZODB.not.there'})
...
...
@@ -70,7 +70,7 @@ def test_integration():
>>> a3.__Broken_state__
{'x': 1}
Let's clean up:
>>> db.close()
...
...
src/ZODB/tests/testCache.py
View file @
fc049e1f
...
...
@@ -178,7 +178,7 @@ class LRUCacheTests(CacheTestBase):
CONNS
=
3
for
i
in
range
(
CONNS
):
self
.
noodle_new_connection
()
self
.
assertEquals
(
self
.
db
.
cacheSize
(),
CACHE_SIZE
*
CONNS
)
details
=
self
.
db
.
cacheDetailSize
()
self
.
assertEquals
(
len
(
details
),
CONNS
)
...
...
@@ -189,7 +189,7 @@ class LRUCacheTests(CacheTestBase):
# The (poorly named) cache size is a target for non-ghosts.
# The cache *usually* contains non-ghosts, so that the
# size normally exceeds the target size.
#self.assertEquals(d['size'], CACHE_SIZE)
def
checkDetail
(
self
):
...
...
@@ -211,7 +211,7 @@ class LRUCacheTests(CacheTestBase):
# deactivated before the MinPO objects.
#
# - Without the gc call, the cache will contain ghost MinPOs
# and the check of the MinPO count below will fail. That's
# and the check of the MinPO count below will fail. That's
# because the counts returned by cacheDetail include ghosts.
#
# - If the mapping object containing the MinPOs isn't
...
...
@@ -219,7 +219,7 @@ class LRUCacheTests(CacheTestBase):
# the test will fail anyway.
#
# This test really needs to be thought through and documented
# better.
# better.
for
klass
,
count
in
self
.
db
.
cacheDetail
():
...
...
src/ZODB/tests/test_cache.py
View file @
fc049e1f
...
...
@@ -73,7 +73,7 @@ class CacheTests:
After committing a transaction and calling cacheGC(), there
should be cache-size (4) objects in the cache. One of the
RegularObjects was deactivated.
>>> cn._cache.ringlen()
4
>>> RegularObject.deactivations
...
...
@@ -81,7 +81,7 @@ class CacheTests:
If we explicitly activate the objects again, the ringlen
should go back up to 5.
>>> for o in L:
... o._p_activate()
>>> cn._cache.ringlen()
...
...
@@ -92,7 +92,7 @@ class CacheTests:
4
>>> RegularObject.deactivations
2
>>> cn.cacheMinimize()
>>> cn._cache.ringlen()
0
...
...
@@ -102,10 +102,10 @@ class CacheTests:
If we activate all the objects again and mark one as modified,
then the one object should not be deactivated even by a
minimize.
>>> for o in L:
... o._p_activate()
>>> o.attr = 1
>>> o.attr = 1
>>> cn._cache.ringlen()
5
>>> cn.cacheMinimize()
...
...
@@ -113,7 +113,7 @@ class CacheTests:
1
>>> RegularObject.deactivations
10
"""
def
test_cache_gc_recalcitrant
(
self
):
...
...
@@ -181,7 +181,7 @@ class CacheTests:
Modify three of the objects and verify that they are
deactivated when the transaction aborts.
>>> for i in range(0, 5, 2):
... L[i].attr = i
>>> [L[i]._p_state for i in range(0, 5, 2)]
...
...
src/ZODB/tests/util.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Conventience function for creating test databases
$Id: util.py,v 1.
4 2004/04/16 15:58:11 jeremy
Exp $
$Id: util.py,v 1.
5 2004/04/19 21:19:07 tim_one
Exp $
"""
import
time
...
...
@@ -36,7 +36,7 @@ def pack(db):
db
.
pack
(
time
.
time
()
+
1
)
class
P
(
persistent
.
Persistent
):
def
__init__
(
self
,
name
):
self
.
name
=
name
...
...
src/ZODB/tests/warnhook.py
View file @
fc049e1f
...
...
@@ -55,4 +55,3 @@ class WarningsHook:
def
clear
(
self
):
self
.
warnings
=
[]
src/ZODB/zodb4/conversion.py
View file @
fc049e1f
...
...
@@ -83,7 +83,7 @@ class DataRecordConvertingTxn(object):
skipped
+=
1
continue
sio
=
StringIO
()
p
=
Pickler
(
sio
,
1
)
p
.
persistent_id
=
get_persistent_id
...
...
@@ -118,7 +118,7 @@ them on zope3-dev.
In any case, keep your original data file in case you decide to rerun
the conversion.
"""
...
...
src/ZODB/zodb4/main.py
View file @
fc049e1f
...
...
@@ -55,7 +55,7 @@ class ConversionApp:
self
.
parse_args
(
args
)
def
run
(
self
):
# Load server-independent site config
from
zope.configuration
import
xmlconfig
context
=
xmlconfig
.
file
(
'site.zcml'
,
execute
=
True
)
...
...
src/ZODB/zodb4/z4errors.py
View file @
fc049e1f
...
...
@@ -60,4 +60,3 @@ class CorruptedDataError(CorruptedError):
class
FileStorageQuotaError
(
FileStorageError
,
StorageSystemError
):
"""File storage quota exceeded."""
src/ZODB/zodb4/z4interfaces.py
View file @
fc049e1f
...
...
@@ -26,7 +26,7 @@ the public APIs of the database.
The IDatabase, IConnection, and ITransactionAttrs interfaces describe
private APIs used by the implementation.
$Id: z4interfaces.py,v 1.
2 2004/02/20 19:01:07 jeremy
Exp $
$Id: z4interfaces.py,v 1.
3 2004/04/19 21:19:09 tim_one
Exp $
"""
from
ZODB.zodb4
import
z4utils
...
...
@@ -238,7 +238,7 @@ class POSKeyError(KeyError, POSError):
## Attributes:
## obj is the invalid object
## jar is the manager that attempted to store it.
## obj._p_jar != jar
## """
...
...
@@ -248,7 +248,7 @@ class POSKeyError(KeyError, POSError):
## def __str__(self):
## return "Invalid reference to object %s." % _fmt_oid(self.obj._p_jar)
##class IAppDatabase(Interface):
## """Interface exported by database to applications.
...
...
src/persistent/interfaces.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Persistence Interfaces
$Id: interfaces.py,v 1.
3 2004/02/24 13:54:05 srichter
Exp $
$Id: interfaces.py,v 1.
4 2004/04/19 21:19:09 tim_one
Exp $
"""
try
:
from
zope.interface
import
Interface
...
...
@@ -286,7 +286,7 @@ class ICache(Interface):
unreferenced objects in memory. We assume that there is a good
chance the object will be used again soon, so keeping it memory
avoids the cost of recreating the object.
An ICache implementation is intended for use by an
IPersistentDataManager.
"""
...
...
@@ -307,7 +307,7 @@ class ICache(Interface):
"""Make all of the objects in oids ghosts.
`oids` is an iterable object that yields oids.
The cache must attempt to change each object to a ghost by
calling _p_deactivate().
...
...
@@ -330,7 +330,7 @@ class ICache(Interface):
def
statistics
():
"""Return dictionary of statistics about cache size.
Contains at least the following keys:
active -- number of active objects
ghosts -- number of ghost objects
...
...
src/persistent/tests/persistenttestbase.py
View file @
fc049e1f
...
...
@@ -351,7 +351,7 @@ class PersistentTest(Test):
# verify that the inc is reflected:
self
.
assertEqual
(
p2
.
x
,
p
.
x
)
# This assertion would be invalid. Interfaces
# are compared by identity and copying doesn't
# preserve identity. We would get false negatives due
...
...
@@ -370,4 +370,3 @@ class PersistentTest(Test):
class
BasePersistentTest
(
Test
):
klass
=
B
has_dict
=
0
src/persistent/tests/test_overriding_attrs.py
View file @
fc049e1f
...
...
@@ -16,7 +16,7 @@
This module tests and documents, through example, overriding attribute
access methods.
$Id: test_overriding_attrs.py,v 1.
6 2004/04/16 15:58:10 jeremy
Exp $
$Id: test_overriding_attrs.py,v 1.
7 2004/04/19 21:19:10 tim_one
Exp $
"""
from
persistent
import
Persistent
...
...
@@ -26,7 +26,7 @@ from ZODB.tests.util import DB
class
SampleOverridingGetattr
(
Persistent
):
"""Example of overriding __getattr__
"""
def
__getattr__
(
self
,
name
):
"""Get attributes that can't be gotten the usual way
...
...
@@ -59,7 +59,7 @@ class SampleOverridingGetattr(Persistent):
>>> o._p_deactivate()
>>> o._p_changed
And now, if we ask for an attribute it doesn't have,
And now, if we ask for an attribute it doesn't have,
>>> o.eggs
('EGGS', False)
...
...
@@ -87,7 +87,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
The class will have the policy that variables with names starting
with 'tmp_' will be volatile.
"""
def
__init__
(
self
,
**
kw
):
...
...
@@ -107,7 +107,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> o._p_changed
0
>>> o._p_oid
>>> o._p_jar
>>> o._p_jar
>>> o.x
1
>>> o.y
...
...
@@ -116,7 +116,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
AttributeError: y
Next, we'll save the object in a database so that we can
deactivate it:
deactivate it:
>>> db = DB()
>>> conn = db.open()
...
...
@@ -136,10 +136,10 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
0
It works for missing attribes too:
>>> o._p_deactivate()
>>> o._p_changed
>>> o.y
Traceback (most recent call last):
...
...
...
@@ -179,9 +179,9 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
meth
=
getattr
(
self
.
__class__
,
name
,
None
)
if
meth
is
None
:
raise
AttributeError
,
name
return
meth
.
__get__
(
self
,
self
.
__class__
)
def
__setattr__
(
self
,
name
,
value
):
"""Set an attribute value
...
...
@@ -219,9 +219,9 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> 'x' in o.__dict__
False
Next, we'll save the object in a database so that we can
deactivate it:
deactivate it:
>>> db = DB()
>>> conn = db.open()
...
...
@@ -243,7 +243,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
1
Now, if commit:
>>> transaction.commit()
>>> o._p_changed
0
...
...
@@ -263,7 +263,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
0
>>> o.tmp_foo
3
We always close databases after we use them:
>>> db.close()
...
...
@@ -288,7 +288,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
if
not
name
.
startswith
(
'tmp_'
):
self
.
_p_changed
=
1
def
__delattr__
(
self
,
name
):
"""Delete an attribute value
...
...
@@ -321,7 +321,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
AttributeError: x
Next, we'll save the object in a database so that we can
deactivate it:
deactivate it:
>>> db = DB()
>>> conn = db.open()
...
...
@@ -348,7 +348,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
3
Now, if commit:
>>> transaction.commit()
>>> o._p_changed
0
...
...
@@ -370,7 +370,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
Traceback (most recent call last):
...
AttributeError: tmp_z
We always close databases after we use them:
>>> db.close()
...
...
@@ -392,10 +392,10 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
return
del
self
.
__dict__
[
'__secret__'
][
name
]
if
not
name
.
startswith
(
'tmp_'
):
self
.
_p_changed
=
1
def
test_suite
():
from
doctest
import
DocTestSuite
...
...
src/persistent/tests/test_pickle.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Basic pickling tests
$Id: test_pickle.py,v 1.
5 2004/02/19 18:13:34 jeremy
Exp $
$Id: test_pickle.py,v 1.
6 2004/04/19 21:19:10 tim_one
Exp $
"""
from
persistent
import
Persistent
...
...
@@ -70,7 +70,7 @@ def test_basic_pickling():
1
>>> pickle.loads(pickle.dumps(x, 1)) == x
1
XXX disable until Python 2.3.4 >>> pickle.loads(pickle.dumps(x, 2)) == x
1
...
...
@@ -160,7 +160,7 @@ def test_pickling_w_slots_only():
1
>>> pickle.loads(pickle.dumps(x, 1)) == x
1
XXX disable until Python 2.3.4 >>> pickle.loads(pickle.dumps(x, 2)) == x
1
...
...
src/persistent/wref.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""ZODB-based persistent weakrefs
$Id: wref.py,v 1.
2 2004/02/19 02:59:30 jeremy
Exp $
$Id: wref.py,v 1.
3 2004/04/19 21:19:09 tim_one
Exp $
"""
from
persistent
import
Persistent
...
...
@@ -46,7 +46,7 @@ class WeakRef(object):
>>> WeakRef(ob) == ref
True
>>> ob2 = persistent.list.PersistentList([1])
>>> WeakRef(ob2) == ref
False
...
...
@@ -54,7 +54,7 @@ class WeakRef(object):
Lets save the reference and the referenced object in a database:
>>> db = ZODB.tests.util.DB()
>>> conn1 = db.open()
>>> conn1.root()['ob'] = ob
>>> conn1.root()['ref'] = ref
...
...
@@ -83,9 +83,9 @@ class WeakRef(object):
KeyError: 'ob'
Trying to dereference the reference returns None:
>>> conn3.root()['ref']()
Trying to get a hash, raises a type error:
>>> hash(conn3.root()['ref'])
...
...
@@ -94,7 +94,7 @@ class WeakRef(object):
TypeError: Weakly-referenced object has gone away
Always explicitly close databases: :)
>>> db.close()
"""
...
...
@@ -133,8 +133,8 @@ class WeakRef(object):
raise
TypeError
(
'Weakly-referenced object has gone away'
)
return
self
==
other
class
PersistentWeakKeyDictionary
(
Persistent
):
"""Persistent weak key dictionary
...
...
@@ -170,9 +170,9 @@ class PersistentWeakKeyDictionary(Persistent):
[True, True, True, False]
We can add the dict and the referenced objects to a database:
>>> db = ZODB.tests.util.DB()
>>> conn1 = db.open()
>>> conn1.root()['p1'] = p1
>>> conn1.root()['d'] = d
...
...
@@ -217,7 +217,7 @@ class PersistentWeakKeyDictionary(Persistent):
Now if we access the dictionary in a new connection, it no longer
has p2:
>>> conn3 = db.open()
>>> d = conn3.root()['d']
>>> l = [(str(k), d[k], d.get(k)) for k in d]
...
...
@@ -227,17 +227,17 @@ class PersistentWeakKeyDictionary(Persistent):
It's worth nothing that that the versions of the dictionary in
conn1 and conn2 still have p2, because p2 is still in the caches
for those connections.
for those connections.
Always explicitly close databases: :)
>>> db.close()
"""
# XXX it is expensive trying to load dead objects from the database.
# It would be helpful if the data manager/connection cached these.
def
__init__
(
self
,
adict
=
None
,
**
kwargs
):
self
.
data
=
{}
if
adict
is
not
None
:
...
...
@@ -259,13 +259,13 @@ class PersistentWeakKeyDictionary(Persistent):
if
k
()
is
not
None
])
Persistent
.
__setstate__
(
self
,
state
)
def
__setitem__
(
self
,
key
,
value
):
self
.
data
[
WeakRef
(
key
)]
=
value
def
__getitem__
(
self
,
key
):
return
self
.
data
[
WeakRef
(
key
)]
def
__delitem__
(
self
,
key
):
del
self
.
data
[
WeakRef
(
key
)]
...
...
@@ -286,7 +286,7 @@ class PersistentWeakKeyDictionary(Persistent):
def
__contains__
(
self
,
key
):
return
WeakRef
(
key
)
in
self
.
data
def
__iter__
(
self
):
for
k
in
self
.
data
:
yield
k
()
...
...
@@ -297,6 +297,5 @@ class PersistentWeakKeyDictionary(Persistent):
else
:
for
k
,
v
in
adict
.
items
():
self
.
data
[
WeakRef
(
k
)]
=
v
# XXX Someone else can fill out the rest of the methods, with tests. :)
src/transaction/_manager.py
View file @
fc049e1f
...
...
@@ -91,4 +91,3 @@ class ThreadTransactionManager(object):
tid
=
thread
.
get_ident
()
L
=
self
.
_synchs
.
get
(
tid
)
L
.
remove
(
synch
)
src/transaction/interfaces.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Transaction Interfaces
$Id: interfaces.py,v 1.
7 2004/02/24 13:52:05 srichter
Exp $
$Id: interfaces.py,v 1.
8 2004/04/19 21:19:10 tim_one
Exp $
"""
try
:
from
zope.interface
import
Interface
...
...
@@ -38,7 +38,7 @@ class IDataManager(Interface):
two-phase commit.
- The savepoint api may need some more thought.
"""
def
prepare
(
transaction
):
...
...
@@ -54,7 +54,7 @@ class IDataManager(Interface):
The transaction must match that used for preceeding
savepoints, if any.
"""
# This is equivalent to zodb3's tpc_begin, commit, and
# tpc_vote combined.
...
...
@@ -77,7 +77,7 @@ class IDataManager(Interface):
The prepare method must be called, with the same transaction,
before calling commit.
"""
# This is equivalent to zodb3's tpc_finish
...
...
@@ -87,7 +87,7 @@ class IDataManager(Interface):
Should return an object implementing IRollback that can be used
to rollback to the savepoint.
Note that (unlike zodb3) this doesn't use a 2-phase commit
protocol. If this call fails, or if a rollback call on the
result fails, the (containing) transaction should be
...
...
src/transaction/tests/test_SampleDataManager.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Sample objects for use in tests
$Id: test_SampleDataManager.py,v 1.
2 2004/02/20 16:56:57 fdrak
e Exp $
$Id: test_SampleDataManager.py,v 1.
3 2004/04/19 21:19:11 tim_on
e Exp $
"""
class
DataManager
(
object
):
...
...
@@ -78,7 +78,7 @@ class DataManager(object):
>>> dm.commit(t1)
Our changes are"permanent". The state reflects the changes and the
delta has been reset to 0.
delta has been reset to 0.
>>> dm.state
1
...
...
@@ -139,7 +139,7 @@ class DataManager(object):
TypeError: ('Transaction missmatch', '2', '1')
>>> dm.prepare(t1)
"""
if
self
.
prepared
:
raise
TypeError
(
'Already prepared'
)
...
...
@@ -183,7 +183,7 @@ class DataManager(object):
If savepoints are used, abort must be passed the same
transaction:
>>> dm.inc()
>>> r = dm.savepoint(t1)
>>> t2 = '2'
...
...
@@ -208,15 +208,15 @@ class DataManager(object):
Of course, the transactions passed to prepare and abort must
match:
>>> dm.prepare(t1)
>>> dm.abort(t2)
Traceback (most recent call last):
...
TypeError: ('Transaction missmatch', '2', '1')
>>> dm.abort(t1)
"""
self
.
_checkTransaction
(
transaction
)
...
...
@@ -262,7 +262,7 @@ class DataManager(object):
If course, the transactions given to prepare and commit must
be the same:
>>> dm.inc()
>>> t3 = '3'
>>> dm.prepare(t3)
...
...
@@ -270,7 +270,7 @@ class DataManager(object):
Traceback (most recent call last):
...
TypeError: ('Transaction missmatch', '2', '3')
"""
if
not
self
.
prepared
:
raise
TypeError
(
'Not prepared to commit'
)
...
...
src/transaction/util.py
View file @
fc049e1f
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Utility classes or functions
$Id: util.py,v 1.
2 2004/02/20 16:56:56 fdrak
e Exp $
$Id: util.py,v 1.
3 2004/04/19 21:19:10 tim_on
e Exp $
"""
from
transaction.interfaces
import
IRollback
...
...
@@ -37,7 +37,7 @@ class NoSavepointSupportRollback:
NotImplementedError: """
\
"""DataManager data managers do not support """
\
"""savepoints (aka subtransactions
"""
implements
(
IRollback
)
...
...
test.py
View file @
fc049e1f
...
...
@@ -738,7 +738,7 @@ def process_args(argv=None):
elif
k
==
"-b"
:
build
=
True
elif
k
==
"-B"
:
build
=
build_inplace
=
True
build
=
build_inplace
=
True
elif
k
==
"-c"
:
# make sure you have a recent version of pychecker
if
not
os
.
environ
.
get
(
"PYCHECKER"
):
...
...
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