Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
936c9540
Commit
936c9540
authored
Nov 17, 2011
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modernized type introspection
parent
af40f33f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
21 additions
and
36 deletions
+21
-36
src/BTrees/check.py
src/BTrees/check.py
+3
-5
src/ZEO/ClientStorage.py
src/ZEO/ClientStorage.py
+2
-3
src/ZEO/monitor.py
src/ZEO/monitor.py
+1
-2
src/ZEO/scripts/cache_stats.py
src/ZEO/scripts/cache_stats.py
+1
-2
src/ZEO/tests/stress.py
src/ZEO/tests/stress.py
+1
-2
src/ZEO/zrpc/client.py
src/ZEO/zrpc/client.py
+3
-4
src/ZEO/zrpc/server.py
src/ZEO/zrpc/server.py
+1
-2
src/ZEO/zrpc/smac.py
src/ZEO/zrpc/smac.py
+2
-3
src/ZODB/scripts/analyze.py
src/ZODB/scripts/analyze.py
+1
-2
src/ZODB/scripts/checkbtrees.py
src/ZODB/scripts/checkbtrees.py
+2
-4
src/ZODB/scripts/fsrefs.py
src/ZODB/scripts/fsrefs.py
+1
-2
src/ZODB/scripts/migrate.py
src/ZODB/scripts/migrate.py
+2
-3
src/ZODB/tests/TransactionalUndoStorage.py
src/ZODB/tests/TransactionalUndoStorage.py
+1
-2
No files found.
src/BTrees/check.py
View file @
936c9540
...
@@ -32,8 +32,6 @@ addresses and/or object identity (the synthesized bucket has an address
...
@@ -32,8 +32,6 @@ addresses and/or object identity (the synthesized bucket has an address
that doesn't exist in the actual BTree).
that doesn't exist in the actual BTree).
"""
"""
from
types
import
TupleType
from
BTrees.OOBTree
import
OOBTree
,
OOBucket
,
OOSet
,
OOTreeSet
from
BTrees.OOBTree
import
OOBTree
,
OOBucket
,
OOSet
,
OOTreeSet
from
BTrees.OIBTree
import
OIBTree
,
OIBucket
,
OISet
,
OITreeSet
from
BTrees.OIBTree
import
OIBTree
,
OIBucket
,
OISet
,
OITreeSet
from
BTrees.IOBTree
import
IOBTree
,
IOBucket
,
IOSet
,
IOTreeSet
from
BTrees.IOBTree
import
IOBTree
,
IOBucket
,
IOSet
,
IOTreeSet
...
@@ -122,10 +120,10 @@ def crack_btree(t, is_mapping):
...
@@ -122,10 +120,10 @@ def crack_btree(t, is_mapping):
if
state
is
None
:
if
state
is
None
:
return
BTREE_EMPTY
,
[],
[]
return
BTREE_EMPTY
,
[],
[]
assert
isinstance
(
state
,
TupleTyp
e
)
assert
isinstance
(
state
,
tupl
e
)
if
len
(
state
)
==
1
:
if
len
(
state
)
==
1
:
state
=
state
[
0
]
state
=
state
[
0
]
assert
isinstance
(
state
,
TupleTyp
e
)
and
len
(
state
)
==
1
assert
isinstance
(
state
,
tupl
e
)
and
len
(
state
)
==
1
state
=
state
[
0
]
state
=
state
[
0
]
return
BTREE_ONE
,
state
,
None
return
BTREE_ONE
,
state
,
None
...
@@ -174,7 +172,7 @@ def crack_btree(t, is_mapping):
...
@@ -174,7 +172,7 @@ def crack_btree(t, is_mapping):
def
crack_bucket
(
b
,
is_mapping
):
def
crack_bucket
(
b
,
is_mapping
):
state
=
b
.
__getstate__
()
state
=
b
.
__getstate__
()
assert
isinstance
(
state
,
TupleTyp
e
)
assert
isinstance
(
state
,
tupl
e
)
assert
1
<=
len
(
state
)
<=
2
assert
1
<=
len
(
state
)
<=
2
data
=
state
[
0
]
data
=
state
[
0
]
if
not
is_mapping
:
if
not
is_mapping
:
...
...
src/ZEO/ClientStorage.py
View file @
936c9540
...
@@ -40,7 +40,6 @@ import tempfile
...
@@ -40,7 +40,6 @@ import tempfile
import
thread
import
thread
import
threading
import
threading
import
time
import
time
import
types
import
weakref
import
weakref
import
zc.lockfile
import
zc.lockfile
import
ZEO.interfaces
import
ZEO.interfaces
...
@@ -671,10 +670,10 @@ class ClientStorage(object):
...
@@ -671,10 +670,10 @@ class ClientStorage(object):
def
set_server_addr
(
self
,
addr
):
def
set_server_addr
(
self
,
addr
):
# Normalize server address and convert to string
# Normalize server address and convert to string
if
isinstance
(
addr
,
types
.
StringType
):
if
isinstance
(
addr
,
str
):
self
.
_server_addr
=
addr
self
.
_server_addr
=
addr
else
:
else
:
assert
isinstance
(
addr
,
t
ypes
.
TupleTyp
e
)
assert
isinstance
(
addr
,
t
upl
e
)
# If the server is on a remote host, we need to guarantee
# If the server is on a remote host, we need to guarantee
# that all clients used the same name for the server. If
# that all clients used the same name for the server. If
# they don't, the sortKey() may be different for each client.
# they don't, the sortKey() may be different for each client.
...
...
src/ZEO/monitor.py
View file @
936c9540
...
@@ -19,7 +19,6 @@ $Id$
...
@@ -19,7 +19,6 @@ $Id$
import
asyncore
import
asyncore
import
socket
import
socket
import
time
import
time
import
types
import
logging
import
logging
zeo_version
=
'unknown'
zeo_version
=
'unknown'
...
@@ -139,7 +138,7 @@ class StatsServer(asyncore.dispatcher):
...
@@ -139,7 +138,7 @@ class StatsServer(asyncore.dispatcher):
asyncore
.
dispatcher
.
__init__
(
self
)
asyncore
.
dispatcher
.
__init__
(
self
)
self
.
addr
=
addr
self
.
addr
=
addr
self
.
stats
=
stats
self
.
stats
=
stats
if
type
(
self
.
addr
)
==
t
ypes
.
TupleTyp
e
:
if
type
(
self
.
addr
)
==
t
upl
e
:
self
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
else
:
else
:
self
.
create_socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
self
.
create_socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
...
...
src/ZEO/scripts/cache_stats.py
View file @
936c9540
...
@@ -60,7 +60,6 @@ import sys
...
@@ -60,7 +60,6 @@ import sys
import
time
import
time
import
getopt
import
getopt
import
struct
import
struct
from
types
import
StringType
# we assign ctime locally to facilitate test replacement!
# we assign ctime locally to facilitate test replacement!
from
time
import
ctime
from
time
import
ctime
...
@@ -357,7 +356,7 @@ def U64(s):
...
@@ -357,7 +356,7 @@ def U64(s):
return
struct
.
unpack
(
">Q"
,
s
)[
0
]
return
struct
.
unpack
(
">Q"
,
s
)[
0
]
def
oid_repr
(
oid
):
def
oid_repr
(
oid
):
if
isinstance
(
oid
,
StringType
)
and
len
(
oid
)
==
8
:
if
isinstance
(
oid
,
str
)
and
len
(
oid
)
==
8
:
return
'%16x'
%
U64
(
oid
)
return
'%16x'
%
U64
(
oid
)
else
:
else
:
return
repr
(
oid
)
return
repr
(
oid
)
...
...
src/ZEO/tests/stress.py
View file @
936c9540
...
@@ -27,7 +27,6 @@ from ZEO.tests import forker
...
@@ -27,7 +27,6 @@ from ZEO.tests import forker
import
os
import
os
import
random
import
random
import
types
NUM_TRANSACTIONS_PER_CONN
=
10
NUM_TRANSACTIONS_PER_CONN
=
10
NUM_CONNECTIONS
=
10
NUM_CONNECTIONS
=
10
...
@@ -69,7 +68,7 @@ def work(cn):
...
@@ -69,7 +68,7 @@ def work(cn):
root
=
cn
.
root
()
root
=
cn
.
root
()
obj
=
random
.
choice
(
root
.
values
())
obj
=
random
.
choice
(
root
.
values
())
# walk down to the bottom
# walk down to the bottom
while
not
isinstance
(
obj
.
value
,
types
.
StringType
):
while
not
isinstance
(
obj
.
value
,
str
):
obj
=
obj
.
value
obj
=
obj
.
value
obj
.
value
=
an_object
()
obj
.
value
=
an_object
()
transaction
.
commit
()
transaction
.
commit
()
...
...
src/ZEO/zrpc/client.py
View file @
936c9540
...
@@ -19,7 +19,6 @@ import socket
...
@@ -19,7 +19,6 @@ import socket
import
sys
import
sys
import
threading
import
threading
import
time
import
time
import
types
import
ZEO.zrpc.trigger
import
ZEO.zrpc.trigger
...
@@ -180,12 +179,12 @@ class ConnectionManager(object):
...
@@ -180,12 +179,12 @@ class ConnectionManager(object):
return
addrlist
return
addrlist
def
_guess_type
(
self
,
addr
):
def
_guess_type
(
self
,
addr
):
if
isinstance
(
addr
,
types
.
StringType
):
if
isinstance
(
addr
,
str
):
return
socket
.
AF_UNIX
return
socket
.
AF_UNIX
if
(
len
(
addr
)
==
2
if
(
len
(
addr
)
==
2
and
isinstance
(
addr
[
0
],
types
.
StringType
)
and
isinstance
(
addr
[
0
],
str
)
and
isinstance
(
addr
[
1
],
types
.
IntType
)):
and
isinstance
(
addr
[
1
],
int
)):
return
socket
.
AF_INET
# also denotes IPv6
return
socket
.
AF_INET
# also denotes IPv6
# not anything I know about
# not anything I know about
...
...
src/ZEO/zrpc/server.py
View file @
936c9540
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
##############################################################################
##############################################################################
import
asyncore
import
asyncore
import
socket
import
socket
import
types
# _has_dualstack: True if the dual-stack sockets are supported
# _has_dualstack: True if the dual-stack sockets are supported
try
:
try
:
...
@@ -51,7 +50,7 @@ class Dispatcher(asyncore.dispatcher):
...
@@ -51,7 +50,7 @@ class Dispatcher(asyncore.dispatcher):
self
.
_open_socket
()
self
.
_open_socket
()
def
_open_socket
(
self
):
def
_open_socket
(
self
):
if
type
(
self
.
addr
)
==
t
ypes
.
TupleTyp
e
:
if
type
(
self
.
addr
)
==
t
upl
e
:
if
self
.
addr
[
0
]
==
''
and
_has_dualstack
:
if
self
.
addr
[
0
]
==
''
and
_has_dualstack
:
# Wildcard listen on all interfaces, both IPv4 and
# Wildcard listen on all interfaces, both IPv4 and
# IPv6 if possible
# IPv6 if possible
...
...
src/ZEO/zrpc/smac.py
View file @
936c9540
...
@@ -34,7 +34,6 @@ except ImportError:
...
@@ -34,7 +34,6 @@ except ImportError:
import
socket
import
socket
import
struct
import
struct
import
threading
import
threading
from
types
import
StringType
from
ZEO.zrpc.log
import
log
from
ZEO.zrpc.log
import
log
from
ZEO.zrpc.error
import
DisconnectedError
from
ZEO.zrpc.error
import
DisconnectedError
...
@@ -182,7 +181,7 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
...
@@ -182,7 +181,7 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
if
msg_size
>
input_len
:
if
msg_size
>
input_len
:
if
inp
is
None
:
if
inp
is
None
:
self
.
__inp
=
d
self
.
__inp
=
d
elif
type
(
self
.
__inp
)
is
StringType
:
elif
type
(
self
.
__inp
)
is
str
:
self
.
__inp
=
[
self
.
__inp
,
d
]
self
.
__inp
=
[
self
.
__inp
,
d
]
else
:
else
:
self
.
__inp
.
append
(
d
)
self
.
__inp
.
append
(
d
)
...
@@ -190,7 +189,7 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
...
@@ -190,7 +189,7 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
return
# keep waiting for more input
return
# keep waiting for more input
# load all previous input and d into single string inp
# load all previous input and d into single string inp
if
isinstance
(
inp
,
StringType
):
if
isinstance
(
inp
,
str
):
inp
=
inp
+
d
inp
=
inp
+
d
elif
inp
is
None
:
elif
inp
is
None
:
inp
=
d
inp
=
d
...
...
src/ZODB/scripts/analyze.py
View file @
936c9540
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
import
pickle
import
pickle
import
sys
import
sys
import
types
from
ZODB.FileStorage
import
FileStorage
from
ZODB.FileStorage
import
FileStorage
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
...
@@ -103,7 +102,7 @@ def get_type(record):
...
@@ -103,7 +102,7 @@ def get_type(record):
except
:
except
:
raise
raise
classinfo
=
unpickled
[
0
]
classinfo
=
unpickled
[
0
]
if
isinstance
(
classinfo
,
t
ypes
.
TupleTyp
e
):
if
isinstance
(
classinfo
,
t
upl
e
):
mod
,
klass
=
classinfo
mod
,
klass
=
classinfo
return
"%s.%s"
%
(
mod
,
klass
)
return
"%s.%s"
%
(
mod
,
klass
)
else
:
else
:
...
...
src/ZODB/scripts/checkbtrees.py
View file @
936c9540
...
@@ -8,8 +8,6 @@ Try to find all the BTrees in a Data.fs, call their _check() methods,
...
@@ -8,8 +8,6 @@ Try to find all the BTrees in a Data.fs, call their _check() methods,
and run them through BTrees.check.check().
and run them through BTrees.check.check().
"""
"""
from
types
import
IntType
import
ZODB
import
ZODB
from
ZODB.FileStorage
import
FileStorage
from
ZODB.FileStorage
import
FileStorage
from
BTrees.check
import
check
from
BTrees.check
import
check
...
@@ -48,9 +46,9 @@ def get_subobjects(obj):
...
@@ -48,9 +46,9 @@ def get_subobjects(obj):
except
AttributeError
:
except
AttributeError
:
items
=
()
items
=
()
for
k
,
v
in
items
:
for
k
,
v
in
items
:
if
not
isinstance
(
k
,
IntType
):
if
not
isinstance
(
k
,
int
):
sub
.
append
((
"<key>"
,
k
))
sub
.
append
((
"<key>"
,
k
))
if
not
isinstance
(
v
,
IntType
):
if
not
isinstance
(
v
,
int
):
sub
.
append
((
"[%s]"
%
repr
(
k
),
v
))
sub
.
append
((
"[%s]"
%
repr
(
k
),
v
))
# what if it is a sequence?
# what if it is a sequence?
...
...
src/ZODB/scripts/fsrefs.py
View file @
936c9540
...
@@ -64,7 +64,6 @@ in non-current revisions.
...
@@ -64,7 +64,6 @@ in non-current revisions.
"""
"""
import
traceback
import
traceback
import
types
from
ZODB.FileStorage
import
FileStorage
from
ZODB.FileStorage
import
FileStorage
from
ZODB.TimeStamp
import
TimeStamp
from
ZODB.TimeStamp
import
TimeStamp
...
@@ -88,7 +87,7 @@ def report(oid, data, serial, missing):
...
@@ -88,7 +87,7 @@ def report(oid, data, serial, missing):
print
"last updated: %s, tid=%s"
%
(
ts
,
hex
(
u64
(
serial
)))
print
"last updated: %s, tid=%s"
%
(
ts
,
hex
(
u64
(
serial
)))
print
"refers to invalid object%s:"
%
plural
print
"refers to invalid object%s:"
%
plural
for
oid
,
info
,
reason
in
missing
:
for
oid
,
info
,
reason
in
missing
:
if
isinstance
(
info
,
t
ypes
.
TupleTyp
e
):
if
isinstance
(
info
,
t
upl
e
):
description
=
"%s.%s"
%
info
description
=
"%s.%s"
%
info
else
:
else
:
description
=
str
(
info
)
description
=
str
(
info
)
...
...
src/ZODB/scripts/migrate.py
View file @
936c9540
...
@@ -340,7 +340,6 @@ def doit(srcdb, dstdb, options):
...
@@ -340,7 +340,6 @@ def doit(srcdb, dstdb, options):
# helper to deal with differences between old-style store() return and
# helper to deal with differences between old-style store() return and
# new-style store() return that supports ZEO
# new-style store() return that supports ZEO
import types
class RevidAccumulator:
class RevidAccumulator:
...
@@ -349,12 +348,12 @@ class RevidAccumulator:
...
@@ -349,12 +348,12 @@ class RevidAccumulator:
def _update_from_list(self, list):
def _update_from_list(self, list):
for oid, serial in list:
for oid, serial in list:
if not isinstance(serial,
types.StringType
):
if not isinstance(serial,
str
):
raise serial
raise serial
self.data[oid] = serial
self.data[oid] = serial
def store(self, oid, result):
def store(self, oid, result):
if isinstance(result,
types.StringType
):
if isinstance(result,
str
):
self.data[oid] = result
self.data[oid] = result
elif result is not None:
elif result is not None:
self._update_from_list(result)
self._update_from_list(result)
...
...
src/ZODB/tests/TransactionalUndoStorage.py
View file @
936c9540
...
@@ -17,7 +17,6 @@ Any storage that supports undo() must pass these tests.
...
@@ -17,7 +17,6 @@ Any storage that supports undo() must pass these tests.
"""
"""
import
time
import
time
import
types
from
persistent
import
Persistent
from
persistent
import
Persistent
import
transaction
import
transaction
...
@@ -61,7 +60,7 @@ class TransactionalUndoStorage:
...
@@ -61,7 +60,7 @@ class TransactionalUndoStorage:
def
_transaction_store
(
self
,
oid
,
rev
,
data
,
vers
,
trans
):
def
_transaction_store
(
self
,
oid
,
rev
,
data
,
vers
,
trans
):
r
=
self
.
_storage
.
store
(
oid
,
rev
,
data
,
vers
,
trans
)
r
=
self
.
_storage
.
store
(
oid
,
rev
,
data
,
vers
,
trans
)
if
r
:
if
r
:
if
type
(
r
)
==
types
.
StringType
:
if
type
(
r
)
==
str
:
self
.
__serials
[
oid
]
=
r
self
.
__serials
[
oid
]
=
r
else
:
else
:
for
oid
,
serial
in
r
:
for
oid
,
serial
in
r
:
...
...
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