Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
klaus_wendelin
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
Eteri
klaus_wendelin
Commits
d0cfeea0
Commit
d0cfeea0
authored
Jul 08, 2020
by
Eteri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin: fix byte size calculation of data array
parent
81c776d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
...TemplateItem/portal_components/document.erp5.DataArray.py
+18
-14
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
View file @
d0cfeea0
...
...
@@ -179,7 +179,6 @@ class DataArray(BigFile):
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
array
=
self
.
getArray
()
factor
=
array
.
nbytes
/
array
.
shape
[
0
]
if
if_range
is
not
None
:
# Only send ranges if the data isn't modified, otherwise send
...
...
@@ -241,8 +240,10 @@ class DataArray(BigFile):
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
self
.
getSize
()))
RESPONSE
.
setStatus
(
206
)
# Partial content
# convert ranges from bytes to array indices
RESPONSE
.
write
(
array
[
start
/
factor
:
end
/
factor
].
tobytes
())
# convert array to bytes
data
=
array
[:].
view
(
'<b'
).
reshape
((
-
1
,))[
start
:
end
].
tobytes
()
RESPONSE
.
setBody
(
data
,
lock
=
True
)
else
:
boundary
=
choose_boundary
()
...
...
@@ -268,16 +269,19 @@ class DataArray(BigFile):
draftprefix
,
boundary
))
RESPONSE
.
setStatus
(
206
)
# Partial content
data
=
''
for
start
,
end
in
ranges
:
RESPONSE
.
write
(
'
\
r
\
n
--%s
\
r
\
n
'
%
boundary
)
RESPONSE
.
write
(
'Content-Type: %s
\
r
\
n
'
%
self
.
content_type
)
RESPONSE
.
write
(
'Content-Range: bytes %d-%d/%d
\
r
\
n
\
r
\
n
'
%
(
start
,
end
-
1
,
self
.
getSize
()))
# convert ranges from bytes to array indices
RESPONSE
.
write
(
array
[
start
/
factor
:
end
/
factor
].
tobytes
())
RESPONSE
.
write
(
'
\
r
\
n
--%s--
\
r
\
n
'
%
boundary
)
data
=
'{data}
\
r
\
n
--{boundary}
\
r
\
n
'
\
'Content-Type: {content_type}
\
r
\
n
'
\
'Content-Range: bytes {start:d}-{end:d}/{size:d}
\
r
\
n
\
r
\
n
'
\
'{array}'
.
format
(
data
=
data
,
boundary
=
boundary
,
content_type
=
self
.
content_type
,
start
=
start
,
end
=
end
-
1
,
size
=
self
.
getSize
(),
array
=
array
[:].
view
(
'<b'
).
reshape
((
-
1
,))[
start
:
end
].
tobytes
())
data
=
'{}
\
r
\
n
--{}--
\
r
\
n
'
.
format
(
data
,
boundary
)
RESPONSE
.
setBody
(
data
,
lock
=
True
)
return
True
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