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
Léo-Paul Géneau
erp5
Commits
090d24ba
Commit
090d24ba
authored
Mar 08, 2016
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BusinessTemplate: In guessExtensionOfDocument allow
to use content_type or reference even if the object is broken.
parent
923bd362
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+15
-6
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
090d24ba
...
@@ -765,12 +765,17 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -765,12 +765,17 @@ class ObjectTemplateItem(BaseTemplateItem):
- '.bin' is returned for binary files
- '.bin' is returned for binary files
- '.txt' is returned for text
- '.txt' is returned for text
"""
"""
# Try to guess the extension based on the content_type of the document
# XXX Zope items like DTMLMethod would not
# XXX Zope items like DTMLMethod would not
# implement getContentType method
# implement getContentType method
extension
=
None
extension
=
None
binary
=
'not_identified'
binary
=
'not_identified'
content_type
=
None
if
hasattr
(
document
,
'getContentType'
):
if
hasattr
(
document
,
'getContentType'
):
content_type
=
document
.
getContentType
()
content_type
=
document
.
getContentType
()
elif
isinstance
(
document
,
ERP5BaseBroken
):
content_type
=
getattr
(
document
,
"content_type"
,
None
)
if
content_type
:
lookup_result
=
self
.
getMimetypesRegistryLookupResultOfContenType
(
content_type
)
lookup_result
=
self
.
getMimetypesRegistryLookupResultOfContenType
(
content_type
)
if
lookup_result
:
if
lookup_result
:
# return first registered Extension (if any)
# return first registered Extension (if any)
...
@@ -793,15 +798,19 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -793,15 +798,19 @@ class ObjectTemplateItem(BaseTemplateItem):
return
extension
return
extension
# Try to guess the extension based on the reference of the document
# Try to guess the extension based on the reference of the document
mime
=
MimeTypes
()
mime
=
MimeTypes
()
reference
=
None
if
hasattr
(
document
,
'getReference'
):
if
hasattr
(
document
,
'getReference'
):
reference
=
document
.
getReference
()
reference
=
document
.
getReference
()
elif
isinstance
(
document
,
ERP5BaseBroken
):
reference
=
getattr
(
document
,
"reference"
,
None
)
if
reference
:
if
reference
:
mime_type
=
mime
.
guess_type
(
reference
)
mime_type
=
mime
.
guess_type
(
reference
)
if
mime_type
[
0
]:
if
mime_type
[
0
]:
extension
=
guess_extension
(
mime_type
[
0
])
extension
=
guess_extension
(
mime_type
[
0
])
return
extension
return
extension
# Try to guess the extension based on the title of the document
# Try to guess the extension based on the title of the document
if
hasattr
(
document
,
'title'
):
title
=
getattr
(
document
,
"title"
,
None
)
if
title
:
mime_type
=
mime
.
guess_type
(
document
.
title
)
mime_type
=
mime
.
guess_type
(
document
.
title
)
if
mime_type
[
0
]:
if
mime_type
[
0
]:
extension
=
guess_extension
(
mime_type
[
0
])
extension
=
guess_extension
(
mime_type
[
0
])
...
...
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