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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
erp5
Commits
1b2d4766
Commit
1b2d4766
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
c0203466
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-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
+26
-0
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py
View file @
1b2d4766
...
@@ -8,7 +8,15 @@ if not getSecurityManager().getUser().has_permission('View History', context):
...
@@ -8,7 +8,15 @@ if not getSecurityManager().getUser().has_permission('View History', context):
raise
Unauthorized
()
raise
Unauthorized
()
def
beautifyChange
(
change_dict
):
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
:
unicode
(
property_value
,
'utf-8'
)
except
UnicodeDecodeError
:
property_value
=
'(binary)'
change_list
.
append
(
'%s:%s'
%
(
property_name
,
property_value
))
return
change_list
try
:
try
:
history_size
=
portal
.
portal_preferences
.
getPreferredHtmlStyleZodbHistorySize
()
history_size
=
portal
.
portal_preferences
.
getPreferredHtmlStyleZodbHistorySize
()
...
...
product/ERP5/tests/testZODBHistory.py
View file @
1b2d4766
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
##############################################################################
##############################################################################
import
unittest
import
unittest
import
os
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
...
@@ -144,6 +145,31 @@ class TestZODBHistory(ERP5TypeTestCase):
...
@@ -144,6 +145,31 @@ class TestZODBHistory(ERP5TypeTestCase):
from
zExceptions
import
Unauthorized
from
zExceptions
import
Unauthorized
self
.
assertRaises
(
Unauthorized
,
document
.
Base_viewZODBHistory
)
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'
)))
document
.
setTitle
(
"ロゴ"
)
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'
))
self
.
assertIn
(
'title:ロゴ'
,
change
.
getProperty
(
'changes'
))
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
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