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
6cf56ff5
Commit
6cf56ff5
authored
Mar 24, 2005
by
Christian Theune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
6b77b82d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
14 deletions
+17
-14
branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.py
branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.py
+8
-8
branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt
branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt
+9
-0
branches/ctheune-blobsupport/src/ZODB/Blobs/TODO.txt
branches/ctheune-blobsupport/src/ZODB/Blobs/TODO.txt
+0
-6
No files found.
branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.py
View file @
6cf56ff5
...
...
@@ -26,11 +26,11 @@ class Blob(Persistent):
_p_blob_uncommitted
=
None
_p_blob_data
=
None
def
open
(
self
,
mode
):
def
open
(
self
,
mode
=
"r"
):
"""Returns a file(-like) object for handling the blob data."""
result
=
None
if
mode
==
"r"
:
if
(
mode
.
startswith
(
"r"
)
or
mode
==
"U"
)
:
if
self
.
_current_filename
()
is
None
:
raise
BlobError
,
"Blob does not exist."
...
...
@@ -38,9 +38,9 @@ class Blob(Persistent):
raise
BlobError
,
"Already opened for writing."
self
.
_p_blob_readers
+=
1
result
=
BlobFile
(
self
.
_current_filename
(),
"rb"
,
self
)
result
=
BlobFile
(
self
.
_current_filename
(),
mode
,
self
)
if
mode
==
"w"
:
if
mode
.
startswith
(
"w"
)
:
if
self
.
_p_blob_readers
!=
0
:
raise
BlobError
,
"Already opened for reading."
...
...
@@ -48,9 +48,9 @@ class Blob(Persistent):
self
.
_p_blob_uncommitted
=
utils
.
mktemp
()
self
.
_p_blob_writers
+=
1
result
=
BlobFile
(
self
.
_p_blob_uncommitted
,
"wb"
,
self
)
result
=
BlobFile
(
self
.
_p_blob_uncommitted
,
mode
,
self
)
if
mode
==
"a"
:
if
mode
.
startswith
(
"a"
)
:
if
self
.
_current_filename
()
is
None
:
raise
BlobError
,
"Blob does not exist."
...
...
@@ -60,12 +60,12 @@ class Blob(Persistent):
if
self
.
_p_blob_uncommitted
is
None
:
# Create a new working copy
self
.
_p_blob_uncommitted
=
utils
.
mktmp
()
uncommitted
=
BlobFile
(
self
.
_p_blob_uncommitted
,
"wb"
,
self
)
uncommitted
=
BlobFile
(
self
.
_p_blob_uncommitted
,
mode
,
self
)
utils
.
cp
(
file
(
self
.
_p_blob_data
),
uncommitted
)
uncommitted
.
seek
(
0
)
else
:
# Re-use existing working copy
uncommitted
=
BlobFile
(
self
.
_p_blob_uncommitted
,
"ab"
,
self
)
uncommitted
=
BlobFile
(
self
.
_p_blob_uncommitted
,
mode
,
self
)
self
.
_p_blob_writers
+=
1
result
=
uncommitted
...
...
branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt
View file @
6cf56ff5
...
...
@@ -118,3 +118,12 @@ We can truncate a blob:
>>> f8.read()
''
>>> f8.close()
We can explicitly open Blobs in the different modified modes:
>>> f9 = myblob.open("rb")
>>> f9.mode
'rb'
>>> f9.close()
branches/ctheune-blobsupport/src/ZODB/Blobs/TODO.txt
View file @
6cf56ff5
- Support database import/export
- Support selection of text/binary mode for opening blobs
- Generic wrapper configuration for BlobStorage
Tests
-----
...
...
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