Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodburi
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
zodburi
Commits
81fc69e1
Commit
81fc69e1
authored
Apr 13, 2017
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow bytes units for large_record_size
parent
dc8cb352
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
zodburi/__init__.py
zodburi/__init__.py
+4
-1
zodburi/tests/test_resolvers.py
zodburi/tests/test_resolvers.py
+6
-6
No files found.
zodburi/__init__.py
View file @
81fc69e1
...
...
@@ -23,6 +23,9 @@ connection_parameters = '''
historical_timeout large_record_size
'''
.
strip
().
split
()
bytes_parameters
=
(
'cache_size_bytes'
,
'historical_cache_size_bytes'
,
'large_record_size'
)
parameters
=
dict
(
database_name
=
'database_name'
)
for
parameter
in
connection_parameters
:
parameters
[
'connection_'
+
parameter
]
=
parameter
...
...
@@ -47,7 +50,7 @@ def _get_dbkw(kw):
if parameter in kw:
v = kw.pop(parameter)
if parameter.startswith('
connection_
'):
if parameter
.endswith('
_bytes
')
:
if parameter
s[parameter] in bytes_parameters
:
v = _parse_bytes(v)
else:
v = int(v)
...
...
zodburi/tests/test_resolvers.py
View file @
81fc69e1
...
...
@@ -461,7 +461,7 @@ class TestZConfigURIResolver(unittest.TestCase):
'database_name'
:
'foo'
})
def
test_database_all_options
(
self
):
from
zodburi
import
connection_parameters
from
zodburi
import
connection_parameters
,
bytes_parameters
self
.
tmp
.
write
((
"""
<zodb x>
<mappingstorage>
...
...
@@ -471,7 +471,7 @@ class TestZConfigURIResolver(unittest.TestCase):
</zodb>
"""
%
'
\
n
'
.
join
(
"%s %s"
%
(
name
.
replace
(
'_'
,
'-'
),
'%sMB'
%
i
if
name
.
endswith
(
'_bytes'
)
else
i
,
'%sMB'
%
i
if
name
in
bytes_parameters
else
i
,
)
for
(
i
,
name
)
in
enumerate
(
connection_parameters
)
...
...
@@ -484,10 +484,10 @@ class TestZConfigURIResolver(unittest.TestCase):
self
.
assertTrue
(
isinstance
(
storage
,
MappingStorage
))
expect
=
dict
(
database_name
=
'foo'
)
for
i
,
parameter
in
enumerate
(
connection_parameters
):
parameter
=
'connection_'
+
parameter
expect
[
parameter
]
=
i
if
parameter
.
endswith
(
'_bytes'
)
:
expect
[
parameter
]
*=
1
<<
20
c
parameter
=
'connection_'
+
parameter
expect
[
c
parameter
]
=
i
if
parameter
in
bytes_parameters
:
expect
[
c
parameter
]
*=
1
<<
20
self
.
assertEqual
(
dbkw
,
expect
)
class
TestMappingStorageURIResolver
(
Base
,
unittest
.
TestCase
):
...
...
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