Commit 5560a450 authored by Jérome Perrin's avatar Jérome Perrin

web_renderjs_ui: don't use manage_FTPget to get page code

manage_FTPget is an API to serve the file content to response, it is not
suitable to just get the file/page template content like we need here.
It was causing issues when running through activities, because timerserver
responses does not have the setBase method, but is also wrong because
large files are streamed to response directly.

Zope does not really offer an unified API to get the source of page
templates or files, except the PrincipiaSearchSource method which it uses
for its builtin search engine. It seems suitable to use here as well.

Also add a test for the case where web pages are in a OFS.File, only
the case of PageTemplate was covered.
parent a5db87a1
Pipeline #13638 failed with stage
in 0 seconds
......@@ -21,8 +21,8 @@ for web_page_reference in web_page_reference_list:
else:
# ... or in skin folders
web_page = context.restrictedTraverse(web_page_reference, None)
if web_page is not None and hasattr(web_page, 'manage_FTPget'):
web_page_text_content = web_page.manage_FTPget()
if web_page is not None and hasattr(web_page, 'PrincipiaSearchSource'):
web_page_text_content = web_page.PrincipiaSearchSource()
if web_page_text_content:
for message in portal.ERP5Site_extractTranslationMessageListFromHTML(web_page_text_content):
......
......@@ -25,6 +25,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import StringIO
import textwrap
import time
......@@ -328,6 +329,19 @@ class TestRenderUpdateTranslationData(RenderJSUpgradeTestCase):
translation_data_text_content = self.web_site.WebSite_getTranslationDataTextContent()
self.assertIn('"Message from page template":', translation_data_text_content)
def test_WebSite_getTranslationDataTextContent_extract_from_file(self):
self.portal.portal_skins.custom.manage_addProduct['OFS'].manage_addFile(
'test_portal_skins_gadget.html',
file=StringIO.StringIO(textwrap.dedent('''
<html>
<!--
data-i18n=Message from file
-->
</html>''')))
self.portal.changeSkin(None) # refresh skin cache
translation_data_text_content = self.web_site.WebSite_getTranslationDataTextContent()
self.assertIn('"Message from file":', translation_data_text_content)
def test_WebSite_getTranslationDataTextContent_ignore_draft_web_page(self):
self.portal.web_page_module.newContent(
portal_type='Web Page',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment