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
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
Nicolas Wavrant
ZODB
Commits
5112cb90
Commit
5112cb90
authored
Apr 25, 2007
by
Christian Theune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- some coding-style updates
parent
95147b06
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
25 deletions
+29
-25
src/ZODB/Blobs/Blob.py
src/ZODB/Blobs/Blob.py
+11
-7
src/ZODB/Blobs/__init__.py
src/ZODB/Blobs/__init__.py
+1
-1
src/ZODB/Connection.py
src/ZODB/Connection.py
+2
-2
src/ZODB/FileStorage/fsdump.py
src/ZODB/FileStorage/fsdump.py
+12
-12
src/ZODB/broken.py
src/ZODB/broken.py
+3
-3
No files found.
src/ZODB/Blobs/Blob.py
View file @
5112cb90
...
...
@@ -38,12 +38,14 @@ BLOB_SUFFIX = ".blob"
class
Blob
(
Persistent
):
"""A BLOB supports efficient handling of large data within ZODB."""
zope
.
interface
.
implements
(
IBlob
)
# Binding this to an attribute allows overriding it in the unit tests
if
sys
.
platform
==
'win32'
:
_os_link
=
lambda
self
,
src
,
dst
:
win32file
.
CreateHardLink
(
dst
,
src
,
None
)
_os_link
=
lambda
self
,
src
,
dst
:
win32file
.
CreateHardLink
(
dst
,
src
,
None
)
else
:
_os_link
=
os
.
link
...
...
@@ -92,7 +94,8 @@ class Blob(Persistent):
if
self
.
_p_blob_uncommitted
is
None
:
# Create a new working copy
uncommitted
=
BlobFile
(
self
.
_create_uncommitted_file
(),
mode
,
self
)
uncommitted
=
BlobFile
(
self
.
_create_uncommitted_file
(),
mode
,
self
)
# NOTE: _p_blob data appears by virtue of Connection._setstate
utils
.
cp
(
file
(
self
.
_p_blob_data
),
uncommitted
)
uncommitted
.
seek
(
0
)
...
...
@@ -153,8 +156,8 @@ class Blob(Persistent):
if
os
.
path
.
exists
(
target
):
os
.
unlink
(
target
)
# If there was a file moved aside, bring it back including the
pointer to
# the uncommitted file.
# If there was a file moved aside, bring it back including the
#
pointer to
the uncommitted file.
if
previous_uncommitted
:
os
.
rename
(
target_aside
,
target
)
self
.
_p_blob_uncommitted
=
target
...
...
@@ -179,7 +182,8 @@ class Blob(Persistent):
return
self
.
_p_blob_uncommitted
or
self
.
_p_blob_data
def
_create_uncommitted_file
(
self
):
assert
self
.
_p_blob_uncommitted
is
None
,
"Uncommitted file already exists."
assert
self
.
_p_blob_uncommitted
is
None
,
(
"Uncommitted file already exists."
)
tempdir
=
os
.
environ
.
get
(
'ZODB_BLOB_TEMPDIR'
,
tempfile
.
gettempdir
())
self
.
_p_blob_uncommitted
=
utils
.
mktemp
(
dir
=
tempdir
)
return
self
.
_p_blob_uncommitted
...
...
@@ -276,8 +280,8 @@ class BlobDataManager:
def
_remove_uncommitted_data
(
self
):
self
.
blob
.
_p_blob_clear
()
self
.
fhrefs
.
map
(
lambda
fhref
:
fhref
.
close
())
if
self
.
blob
.
_p_blob_uncommitted
is
not
None
and
\
os
.
path
.
exists
(
self
.
blob
.
_p_blob_uncommitted
):
if
(
self
.
blob
.
_p_blob_uncommitted
is
not
None
and
os
.
path
.
exists
(
self
.
blob
.
_p_blob_uncommitted
)
):
os
.
unlink
(
self
.
blob
.
_p_blob_uncommitted
)
self
.
blob
.
_p_blob_uncommitted
=
None
...
...
src/ZODB/Blobs/__init__.py
View file @
5112cb90
# python package
"""The ZODB Blob package."""
src/ZODB/Connection.py
View file @
5112cb90
...
...
@@ -863,8 +863,8 @@ class Connection(ExportImport, object):
providedBy
=
getattr
(
obj
,
'__providedBy__'
,
None
)
if
providedBy
is
not
None
and
IBlob
in
providedBy
:
obj
.
_p_blob_uncommitted
=
None
obj
.
_p_blob_data
=
\
self
.
_storage
.
loadBlob
(
obj
.
_p_oid
,
serial
,
self
.
_version
)
obj
.
_p_blob_data
=
self
.
_storage
.
loadBlob
(
obj
.
_p_oid
,
serial
,
self
.
_version
)
def
_load_before_or_conflict
(
self
,
obj
):
"""Load non-current state for obj or raise ReadConflictError."""
...
...
src/ZODB/FileStorage/fsdump.py
View file @
5112cb90
...
...
@@ -14,8 +14,8 @@
import
struct
from
ZODB.FileStorage
import
FileIterator
from
ZODB.FileStorage.format
\
import
TRANS_HDR
,
TRANS_HDR_LEN
,
DATA_HDR
,
DATA_HDR_LEN
from
ZODB.FileStorage.format
import
TRANS_HDR
,
TRANS_HDR_LEN
,
DATA_HDR
,
DATA_HDR_LEN
from
ZODB.FileStorage.format
import
DATA_HDR_LEN
from
ZODB.TimeStamp
import
TimeStamp
from
ZODB.utils
import
u64
,
get_pickle_metadata
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
...
...
@@ -24,13 +24,13 @@ def fsdump(path, file=None, with_offset=1):
iter
=
FileIterator
(
path
)
for
i
,
trans
in
enumerate
(
iter
):
if
with_offset
:
print
>>
file
,
"Trans #%05d tid=%016x time=%s offset=%d"
%
\
(
i
,
u64
(
trans
.
tid
),
TimeStamp
(
trans
.
tid
),
trans
.
_pos
)
print
>>
file
,
(
"Trans #%05d tid=%016x time=%s offset=%d"
%
(
i
,
u64
(
trans
.
tid
),
TimeStamp
(
trans
.
tid
),
trans
.
_pos
)
)
else
:
print
>>
file
,
"Trans #%05d tid=%016x time=%s"
%
\
(
i
,
u64
(
trans
.
tid
),
TimeStamp
(
trans
.
tid
))
print
>>
file
,
" status=%r user=%r description=%r"
%
\
(
trans
.
status
,
trans
.
user
,
trans
.
description
)
print
>>
file
,
(
"Trans #%05d tid=%016x time=%s"
%
(
i
,
u64
(
trans
.
tid
),
TimeStamp
(
trans
.
tid
))
)
print
>>
file
,
(
" status=%r user=%r description=%r"
%
(
trans
.
status
,
trans
.
user
,
trans
.
description
)
)
for
j
,
rec
in
enumerate
(
trans
):
if
rec
.
data
is
None
:
...
...
@@ -53,8 +53,8 @@ def fsdump(path, file=None, with_offset=1):
else
:
bp
=
""
print
>>
file
,
" data #%05d oid=%016x%s%s class=%s%s"
%
\
(
j
,
u64
(
rec
.
oid
),
version
,
size
,
fullclass
,
bp
)
print
>>
file
,
(
" data #%05d oid=%016x%s%s class=%s%s"
%
(
j
,
u64
(
rec
.
oid
),
version
,
size
,
fullclass
,
bp
)
)
iter
.
close
()
def
fmt
(
p64
):
...
...
@@ -123,8 +123,8 @@ class Dumper:
version
=
self
.
file
.
read
(
vlen
)
print
>>
self
.
dest
,
"version: %r"
%
version
print
>>
self
.
dest
,
"non-version data offset: %d"
%
u64
(
pnv
)
print
>>
self
.
dest
,
\
"previous version data offset: %d"
%
u64
(
sprevdata
)
print
>>
self
.
dest
,
(
"previous version data offset: %d"
%
u64
(
sprevdata
)
)
print
>>
self
.
dest
,
"len(data): %d"
%
dlen
self
.
file
.
read
(
dlen
)
if
not
dlen
:
...
...
src/ZODB/broken.py
View file @
5112cb90
...
...
@@ -281,11 +281,11 @@ class PersistentBroken(Broken, persistent.Persistent):
and persistent broken objects aren't directly picklable:
>>> a.__reduce__()
>>> a.__reduce__()
# doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
BrokenModified:
"""
\
r"""
<persistent broken not.there.Atall instance '\x00\x00\x00\x00****'>
BrokenModified:
<persistent broken not.there.Atall instance '\x00\x00\x00\x00****'>
but you can get their state:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment