Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Amer
erp5
Commits
2d315a81
Commit
2d315a81
authored
Nov 28, 2017
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: support binary data in ZODB History View
It was failing decoding unicode
parent
388c7230
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py
...ateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py
+9
-1
product/ERP5/tests/testZODBHistory.py
product/ERP5/tests/testZODBHistory.py
+24
-0
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py
View file @
2d315a81
...
...
@@ -8,7 +8,15 @@ if not getSecurityManager().getUser().has_permission('View History', context):
raise
Unauthorized
()
def
beautifyChange
(
change_dict
):
return
[
"%s:%s"
%
(
k
,
change_dict
[
k
])
for
k
in
sorted
(
change_dict
.
keys
())]
change_list
=
[]
for
property_name
,
property_value
in
sorted
(
change_dict
.
items
()):
if
isinstance
(
property_value
,
basestring
):
try
:
property_value
=
unicode
(
property_value
,
'utf8'
)
except
UnicodeDecodeError
:
property_value
=
'(binary)'
change_list
.
append
(
'%s:%s'
%
(
property_name
,
property_value
))
return
change_list
try
:
history_size
=
portal
.
portal_preferences
.
getPreferredHtmlStyleZodbHistorySize
()
...
...
product/ERP5/tests/testZODBHistory.py
View file @
2d315a81
...
...
@@ -28,6 +28,7 @@
##############################################################################
import
unittest
import
os
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
...
...
@@ -144,6 +145,29 @@ class TestZODBHistory(ERP5TypeTestCase):
from
zExceptions
import
Unauthorized
self
.
assertRaises
(
Unauthorized
,
document
.
Base_viewZODBHistory
)
def
test_ZODBHistoryBinaryData
(
self
):
"""
Make sure ZODB History view works with binary content
"""
self
.
loginByUserName
(
'tatuya'
)
document
=
self
.
addOrganisation
(
self
.
id
()).
newContent
(
portal_type
=
'Embedded File'
)
document
.
setFile
(
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'test_data'
,
'images'
,
'erp5_logo.png'
)))
self
.
commit
()
# no encoding error
document
.
Base_viewZODBHistory
()
change
,
=
document
.
Base_getZODBHistoryList
()
self
.
assertIn
(
'data:(binary)'
,
change
.
getProperty
(
'changes'
))
self
.
assertIn
(
'content_type:image/png'
,
change
.
getProperty
(
'changes'
))
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
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