Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Zope
Commits
fb840ce9
Commit
fb840ce9
authored
Nov 20, 2018
by
Jérome Perrin
Committed by
GitHub
Nov 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #396 from perrinjerome/feat/history_tab_for_ofs_file-2.13
Enable history page for OFS.Image.File
parents
dc14c564
9616da88
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletion
+35
-1
doc/CHANGES.rst
doc/CHANGES.rst
+3
-0
src/OFS/Image.py
src/OFS/Image.py
+20
-1
src/OFS/tests/testFileAndImage.py
src/OFS/tests/testFileAndImage.py
+12
-0
No files found.
doc/CHANGES.rst
View file @
fb840ce9
...
...
@@ -22,6 +22,9 @@ Features
- Add wildcard rewrite to sub host name in virtualHostMonster.
(`#317 <https://github.com/zopefoundation/Zope/issues/317>`_)
- Enable ZMI History tab for ``OFS.Image.File``.
(`#396 <https://github.com/zopefoundation/Zope/pull/396>`_)
2.13.28 (2018-04-23)
--------------------
...
...
src/OFS/Image.py
View file @
fb840ce9
...
...
@@ -44,6 +44,9 @@ from OFS.PropertyManager import PropertyManager
from
OFS.role
import
RoleManager
from
OFS.SimpleItem
import
Item_w__name__
from
OFS.History
import
Historical
from
OFS.History
import
html_diff
from
zope.event
import
notify
from
zope.lifecycleevent
import
ObjectModifiedEvent
from
zope.lifecycleevent
import
ObjectCreatedEvent
...
...
@@ -87,7 +90,7 @@ def manage_addFile(self, id, file='', title='', precondition='',
class
File
(
Persistent
,
Implicit
,
PropertyManager
,
RoleManager
,
Item_w__name__
,
Cacheable
):
RoleManager
,
Item_w__name__
,
Historical
,
Cacheable
):
"""A File object is a content object for arbitrary files."""
implements
(
implementedBy
(
Persistent
),
...
...
@@ -125,6 +128,7 @@ class File(Persistent, Implicit, PropertyManager,
+
RoleManager
.
manage_options
+
Item_w__name__
.
manage_options
+
Cacheable
.
manage_options
+
Historical
.
manage_options
)
_properties
=
({
'id'
:
'title'
,
'type'
:
'string'
},
...
...
@@ -500,6 +504,21 @@ class File(Persistent, Implicit, PropertyManager,
message
=
"Saved changes."
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
message
)
def
manage_historyCompare
(
self
,
rev1
,
rev2
,
REQUEST
,
historyComparisonResults
=
''
):
if
self
.
content_type
and
((
self
.
content_type
.
startswith
(
'text'
)
or
self
.
content_type
.
endswith
(
'javascript'
))
and
self
.
get_size
()
<
65536
):
return
File
.
inheritedAttribute
(
'manage_historyCompare'
)(
self
,
rev1
,
rev2
,
REQUEST
,
historyComparisonResults
=
html_diff
(
str
(
rev1
.
data
),
str
(
rev2
.
data
)))
return
File
.
inheritedAttribute
(
'manage_historyCompare'
)(
self
,
rev1
,
rev2
,
REQUEST
,
historyComparisonResults
=
historyComparisonResults
)
def
_get_content_type
(
self
,
file
,
body
,
id
,
content_type
=
None
):
headers
=
getattr
(
file
,
'headers'
,
None
)
if
headers
and
'content-type'
in
headers
:
...
...
src/OFS/tests/testFileAndImage.py
View file @
fb840ce9
...
...
@@ -302,6 +302,18 @@ class FileTests(unittest.TestCase):
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
results
[
0
][
1
],
self
.
file
)
def
testHistoryCompare
(
self
):
self
.
file
.
manage_edit
(
'a'
,
'text/plain'
,
filedata
=
'content_of_a'
)
getattr
(
self
.
app
,
self
.
factory
)(
'b'
,
file
=
'content_of_b'
,
content_type
=
'text/plain'
)
page
=
self
.
file
.
manage_historyCompare
(
self
.
file
,
self
.
app
.
b
,
self
.
app
.
REQUEST
)
self
.
assertTrue
(
'content_of_a'
in
page
)
self
.
assertTrue
(
'content_of_b'
in
page
)
def
test_interfaces
(
self
):
from
zope.interface.verify
import
verifyClass
from
OFS.Image
import
File
...
...
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