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
Labels
Merge Requests
141
Merge Requests
141
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
2d54e1b0
Commit
2d54e1b0
authored
Mar 22, 2023
by
Jérome Perrin
Committed by
Arnaud Fontaine
Jul 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DMS py3
parent
c73c3dd4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
...plateItem/portal_components/document.erp5.TextDocument.py
+12
-2
No files found.
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
View file @
2d54e1b0
...
@@ -315,7 +315,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
...
@@ -315,7 +315,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
return
text_content
,
message
return
text_content
,
message
content_type
=
self
.
getContentType
()
or
DEFAULT_CONTENT_TYPE
content_type
=
self
.
getContentType
()
or
DEFAULT_CONTENT_TYPE
text_content
=
self
.
getData
()
text_content
=
self
.
getData
()
# TODO: don't we need to convert to bytes here ? what if it is PData ?
if
content_type
.
endswith
(
'xml'
):
if
content_type
.
endswith
(
'xml'
):
try
:
try
:
tree
=
etree
.
fromstring
(
text_content
)
tree
=
etree
.
fromstring
(
text_content
)
...
@@ -324,7 +324,10 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
...
@@ -324,7 +324,10 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
except
etree
.
XMLSyntaxError
:
# pylint: disable=catching-non-exception
except
etree
.
XMLSyntaxError
:
# pylint: disable=catching-non-exception
message
=
'Conversion to base format without codec fails'
message
=
'Conversion to base format without codec fails'
elif
content_type
==
'text/html'
:
elif
content_type
==
'text/html'
:
re_match
=
self
.
charset_parser
.
search
(
text_content
)
re_match
=
self
.
charset_parser
.
search
(
# we don't really care about decoding errors for searching this
# regexp
text_content
.
decode
(
'ascii'
,
'replace'
)
if
six
.
PY3
else
text_content
)
message
=
'Conversion to base format succeeds'
message
=
'Conversion to base format succeeds'
if
re_match
is
not
None
:
if
re_match
is
not
None
:
charset
=
re_match
.
group
(
'charset'
)
charset
=
re_match
.
group
(
'charset'
)
...
@@ -374,6 +377,12 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
...
@@ -374,6 +377,12 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
"""Overriden method to check
"""Overriden method to check
permission to access content in raw format
permission to access content in raw format
"""
"""
# XXX Zope4py3: should this return str ??
# We probably have "legacy" documents where `text_content` is a python2
# str encoded as something else than utf-8.
# Maybe we should introduce a new text_content_encoding property and
# expose API to getRawTextContent (as bytes) and getTextContent would return
# the decoded string.
self
.
_checkConversionFormatPermission
(
None
)
self
.
_checkConversionFormatPermission
(
None
)
if
default
is
_MARKER
:
if
default
is
_MARKER
:
return
self
.
_baseGetTextContent
()
return
self
.
_baseGetTextContent
()
...
@@ -406,6 +415,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
...
@@ -406,6 +415,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
return
self
.
_setContentType
(
value
)
return
self
.
_setContentType
(
value
)
def
getData
(
self
,
default
=
_MARKER
):
def
getData
(
self
,
default
=
_MARKER
):
# type: () -> bytes | PData
"""getData must returns original content but TextDocument accepts
"""getData must returns original content but TextDocument accepts
data or text_content to store original content.
data or text_content to store original content.
Fallback on text_content property if data is not defined
Fallback on text_content property if data is not defined
...
...
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