Commit aaf4a10e authored by Jérome Perrin's avatar Jérome Perrin

web_renderjs: optimize post upgrade constraints

by using getDocumentValueList to lookup all documents at once instead
of using getDocumentValue for each document
parent 517a8aed
from DateTime import DateTime
appcache_reference = context.getLayoutProperty("configuration_manifest_url")
getDocumentValue = context.getDocumentValue
error_list = []
if appcache_reference:
appcache_manifest = getDocumentValue(appcache_reference)
appcache_manifest = context.getDocumentValue(appcache_reference)
if not appcache_manifest:
return ['Error: Web Site %s references a non existant appcache %s' % (context.getRelativeUrl(),appcache_reference)]
url_list = context.Base_getListFileFromAppcache()
url_list = [url for url in context.Base_getListFileFromAppcache() if url]
# Check that the manifest is newer than all cached resources.
appcache_manifest_modification_date = appcache_manifest.getObject().getModificationDate()
for url in url_list:
if url:
referenced_document = getDocumentValue(url)
if referenced_document is not None and (
referenced_document.getModificationDate() >
appcache_manifest_modification_date):
if url_list:
for referenced_document in context.getDocumentValueList(reference=url_list):
if referenced_document.getModificationDate() > appcache_manifest_modification_date:
error_list.append(
"Document {} is newer than cache manifest".format(url))
"Document {} is newer than cache manifest".format(referenced_document.getReference()))
if error_list and fixit:
text_list = appcache_manifest.getTextContent().split('\n')
......
......@@ -13,12 +13,18 @@ Base_translateString = context.Base_translateString
translatable_message_set = set([])
web_page_reference_list = context.Base_getTranslationSourceFileList(only_html=1)
web_page_by_reference = {}
if web_page_reference_list:
web_page_list = [
b.getObject() for b in
context.getDocumentValueList(reference=web_page_reference_list)]
web_page_by_reference = {wp.getReference(): wp.getTextContent() for wp in web_page_list}
for web_page_reference in web_page_reference_list:
# Web pages can be in web page module ...
web_page = context.getDocumentValue(web_page_reference)
if web_page is not None:
web_page_text_content = web_page.getTextContent()
else:
web_page_text_content = web_page_by_reference.get(web_page_reference)
if web_page_text_content is None:
# ... or in skin folders
web_page = context.restrictedTraverse(web_page_reference, None)
if web_page is not None and hasattr(web_page, 'PrincipiaSearchSource'):
......
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