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
24b1f8a9
Commit
24b1f8a9
authored
Sep 18, 2008
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed numerous windows issues
parent
1c2e2768
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
16 deletions
+37
-16
src/ZODB/blob.py
src/ZODB/blob.py
+5
-5
src/ZODB/tests/blob_packing.txt
src/ZODB/tests/blob_packing.txt
+2
-2
src/ZODB/tests/blob_transaction.txt
src/ZODB/tests/blob_transaction.txt
+2
-3
src/ZODB/tests/testblob.py
src/ZODB/tests/testblob.py
+28
-6
No files found.
src/ZODB/blob.py
View file @
24b1f8a9
...
...
@@ -298,7 +298,7 @@ class FilesystemHelper:
# want to perform blob storage differently.
def
__init__
(
self
,
base_dir
,
layout_name
=
'automatic'
):
self
.
base_dir
=
os
.
path
.
normpath
(
base_dir
)
+
'/'
self
.
base_dir
=
os
.
path
.
normpath
(
base_dir
)
+
os
.
path
.
sep
self
.
temp_dir
=
os
.
path
.
join
(
base_dir
,
'tmp'
)
if
layout_name
==
'automatic'
:
...
...
@@ -488,8 +488,8 @@ class BushyLayout(object):
"""
blob_path_pattern
=
r
'^'
+
(
r'0x[0-9a-f]{1,2}/*'
*
8
)
+
r'$'
blob_path_pattern
=
re
.
compile
(
blob_path_pattern
)
blob_path_pattern
=
r
e
.
compile
(
r'(0x[0-9a-f]{1,2}\
%s){
7,7}0x[0-9a-f]{1,2}$'
%
os
.
path
.
sep
)
def
oid_to_path
(
self
,
oid
):
directories
=
[]
...
...
@@ -497,12 +497,12 @@ class BushyLayout(object):
# first
for
byte
in
str
(
oid
):
directories
.
append
(
'0x%s'
%
binascii
.
hexlify
(
byte
))
return
'/'
.
join
(
directories
)
return
os
.
path
.
sep
.
join
(
directories
)
def
path_to_oid
(
self
,
path
):
if
self
.
blob_path_pattern
.
match
(
path
)
is
None
:
raise
ValueError
(
"Not a valid OID path: `%s`"
%
path
)
path
=
path
.
split
(
'/'
)
path
=
path
.
split
(
os
.
path
.
sep
)
# Each path segment stores a byte in hex representation. Turn it into
# an int and then get the character for our byte string.
oid
=
''
.
join
(
binascii
.
unhexlify
(
byte
[
2
:])
for
byte
in
path
)
...
...
src/ZODB/tests/blob_packing.txt
View file @
24b1f8a9
...
...
@@ -146,7 +146,7 @@ revision as well as the entire directory:
Clean up our blob directory and database:
>>>
shutil.
rmtree(blob_dir)
>>> rmtree(blob_dir)
>>> base_storage.close()
>>> os.unlink(storagefile)
>>> os.unlink(storagefile+".index")
...
...
@@ -273,4 +273,4 @@ knowledge that the underlying storage's pack method is also called:
Clean up our blob directory:
>>>
shutil.
rmtree(blob_dir)
>>> rmtree(blob_dir)
src/ZODB/tests/blob_transaction.txt
View file @
24b1f8a9
...
...
@@ -381,6 +381,5 @@ We don't need the storage directory and databases anymore::
>>> tm1.abort()
>>> tm2.abort()
>>> database.close()
>>> import shutil
>>> shutil.rmtree(blob_dir)
>>> shutil.rmtree(blob_dir2)
>>> rmtree(blob_dir)
>>> rmtree(blob_dir2)
src/ZODB/tests/testblob.py
View file @
24b1f8a9
...
...
@@ -12,7 +12,7 @@
#
##############################################################################
import
base64
,
os
,
re
,
shutil
,
tempfile
,
unittest
import
base64
,
os
,
re
,
shutil
,
stat
,
sys
,
tempfile
,
unittest
import
time
from
zope.testing
import
doctest
,
renormalizing
import
ZODB.tests.util
...
...
@@ -473,6 +473,11 @@ def secure_blob_directory():
"""
# On windows, we can't create secure blob directories, at least not
# with APIs in the standard library, so there's no point in testing
# this.
if
sys
.
platform
==
'win32'
:
del
secure_blob_directory
def
loadblob_tmpstore
():
"""
...
...
@@ -520,13 +525,26 @@ def loadblob_tmpstore():
>>> database.close()
>>> import shutil
>>>
shutil.
rmtree(blob_dir)
>>> rmtree(blob_dir)
>>> os.unlink(storagefile)
>>> os.unlink(storagefile+".index")
>>> os.unlink(storagefile+".tmp")
"""
def
setUp
(
test
):
ZODB
.
tests
.
util
.
setUp
(
test
)
def
rmtree
(
path
):
for
path
,
dirs
,
files
in
os
.
walk
(
path
,
False
):
for
fname
in
files
:
fname
=
os
.
path
.
join
(
path
,
fname
)
os
.
chmod
(
fname
,
stat
.
S_IWUSR
)
os
.
remove
(
fname
)
for
dname
in
dirs
:
dname
=
os
.
path
.
join
(
path
,
dname
)
os
.
rmdir
(
dname
)
test
.
globs
[
'rmtree'
]
=
rmtree
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
@@ -536,22 +554,26 @@ def test_suite():
"blob_packing.txt"
,
"blob_importexport.txt"
,
"blob_consume.txt"
,
"blob_tempdir.txt"
,
optionflags
=
doctest
.
ELLIPSIS
,
setUp
=
ZODB
.
tests
.
util
.
setUp
,
setUp
=
setUp
,
tearDown
=
ZODB
.
tests
.
util
.
tearDown
,
))
suite
.
addTest
(
doctest
.
DocFileSuite
(
"blob_layout.txt"
,
optionflags
=
doctest
.
ELLIPSIS
|
doctest
.
NORMALIZE_WHITESPACE
,
setUp
=
ZODB
.
tests
.
util
.
setUp
,
setUp
=
setUp
,
tearDown
=
ZODB
.
tests
.
util
.
tearDown
,
checker
=
renormalizing
.
RENormalizing
([
(
re
.
compile
(
r'
[%(sep)s]
'
%
dict
(
sep
=
os
.
path
.
sep
)),
'/'
),
(
re
.
compile
(
r'
\
%(sep)s
' % dict(sep=os.path.sep)), '
/
'),
(re.compile(r'
\
S
+/
((
old
|
bushy
|
lawn
)
/
\
S
+/
foo
[
23456
]
?
)
'), r'
\
1
'),
]),
))
suite.addTest(doctest.DocTestSuite(
setUp
=
ZODB
.
tests
.
util
.
setUp
,
setUp=setUp,
tearDown=ZODB.tests.util.tearDown,
checker = renormalizing.RENormalizing([
(re.compile(r'
\
%
(
sep
)
s
\
%
(
sep
)
s
' % dict(sep=os.path.sep)), '
/
'),
(re.compile(r'
\
%
(
sep
)
s
' % dict(sep=os.path.sep)), '
/
'),
]),
))
suite.addTest(unittest.makeSuite(BlobUndoTests))
...
...
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