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
Binh
erp5
Commits
10445878
Commit
10445878
authored
Jan 20, 2012
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only textual conversions can use substitution. Add testing for this change.
parent
f7ea2361
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
product/ERP5/Document/TextDocument.py
product/ERP5/Document/TextDocument.py
+7
-5
product/ERP5OOo/tests/testDms.py
product/ERP5OOo/tests/testDms.py
+5
-3
No files found.
product/ERP5/Document/TextDocument.py
View file @
10445878
...
...
@@ -36,7 +36,7 @@ from Products.ERP5.Document.Document import Document, ConversionError, _MARKER,
from
Products.ERP5.Document.File
import
File
from
Products.ERP5Type.WebDAVSupport
import
TextContent
import
re
from
Products.ERP5.Document.Document
import
VALID_IMAGE_FORMAT_LIST
from
Products.ERP5.Document.Document
import
VALID_IMAGE_FORMAT_LIST
,
VALID_TEXT_FORMAT_LIST
import
cStringIO
from
string
import
Template
...
...
@@ -179,10 +179,12 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
self
.
setConversion
(
result
,
original_mime_type
,
**
kw
)
else
:
mime_type
,
result
=
self
.
getConversion
(
**
kw
)
if
substitution_method_parameter_dict
is
None
:
substitution_method_parameter_dict
=
{}
result
=
self
.
_substituteTextContent
(
result
,
safe_substitute
=
safe_substitute
,
**
substitution_method_parameter_dict
)
if
format
in
VALID_TEXT_FORMAT_LIST
:
# only textual content can be sustituted
if
substitution_method_parameter_dict
is
None
:
substitution_method_parameter_dict
=
{}
result
=
self
.
_substituteTextContent
(
result
,
safe_substitute
=
safe_substitute
,
**
substitution_method_parameter_dict
)
return
original_mime_type
,
result
else
:
# text_content is not set, return empty string instead of None
...
...
product/ERP5OOo/tests/testDms.py
View file @
10445878
...
...
@@ -2091,7 +2091,9 @@ return 1
image_document
.
edit
(
file
=
upload_file
)
web_page_document
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
"Web Page"
)
web_page_document
.
setTextContent
(
'<b> test </b>'
)
web_page_document
.
setTextContent
(
'<b> test </b> $website_url $website_url'
)
# a Web Page can generate dynamic text so test is as well
web_page_document
.
setTextContentSubstitutionMappingMethodId
(
'WebPage_getStandardSubstitutionMappingDict'
)
self
.
stepTic
()
ooo_document_url
=
'%s/%s'
%
(
self
.
portal
.
absolute_url
(),
ooo_document
.
getRelativeUrl
())
...
...
@@ -2704,8 +2706,8 @@ class TestDocumentPerformance(TestDocumentMixin):
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestDocument
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestDocumentWithSecurity
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestDocumentPerformance
))
#
suite.addTest(unittest.makeSuite(TestDocumentWithSecurity))
#
suite.addTest(unittest.makeSuite(TestDocumentPerformance))
return
suite
...
...
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