From a5f42fac29b3c52819a1da07aa6e9e94f247a9a0 Mon Sep 17 00:00:00 2001 From: voisardf Date: Fri, 30 Aug 2024 10:32:14 +0200 Subject: [PATCH] renamed parameter as requested --- dev/config/pyramid_oereb.yml.mako | 6 +++--- doc/source/changes.rst | 2 +- .../contrib/print_proxy/mapfish_print/mapfish_print.py | 6 +++--- .../resources/test_config.yml | 2 +- .../test_mapfish_print_configuration.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dev/config/pyramid_oereb.yml.mako b/dev/config/pyramid_oereb.yml.mako index 991f220fd4..079a06f913 100644 --- a/dev/config/pyramid_oereb.yml.mako +++ b/dev/config/pyramid_oereb.yml.mako @@ -85,7 +85,7 @@ pyramid_oereb: # Will make an estimation of the total length of the Table of Content (TOC) and control that the page # numbering in the output pdf is consistent with TOC numbering. If it is known that the TOC is very long and # could run over more than one page, it is preferred to set this to true. The drawback is that it might need - # more time to generate the PDF. If set to false, the general_toc_length setting below will be used. If it is + # more time to generate the PDF. If set to false, the expected_toc_length setting below will be used. If it is # not set it will assume that only one TOC page exists, and this can lead to wrong numbering in the TOC, which # will be fixed by a second PDF extract call that has an impact on performance. compute_toc_pages: false @@ -95,8 +95,8 @@ pyramid_oereb: # In both cases (computing an estimate or setting a default for the number of TOC pages) the exact number of TOC # pages is extracted from the created PDF and if it differs from the expected value the PDF is created a second # time with the correct page numbers. - # Note that if "compute_toc_pages" is set true the "general_toc_length" is not taken into account. - general_toc_length: 2 + # Note that if "compute_toc_pages" is set true the "expected_toc_length" is not taken into account. + expected_toc_length: 2 # Specify any additional URL parameters that the print shall use for WMS calls wms_url_params: TRANSPARENT: 'true' diff --git a/doc/source/changes.rst b/doc/source/changes.rst index af31a10664..df897b75d8 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -8,7 +8,7 @@ to adapt in your project configuration, database etc. when upgrading to a new ve Version 2.6.0 ------------- -* New parameter 'general_toc_length' allows to define a default table of content pages number avoiding a second +* New parameter 'expected_toc_length' allows to define a default table of content pages number avoiding a second call for the pdf extract in most cases. This value should be set if most of the PDF extracts have the same number of TOC pages. Default setting: 2 diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index 64b3c9458f..62dee7749e 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -78,8 +78,8 @@ def __call__(self, value, system): if print_config.get('compute_toc_pages', False): extract_as_dict['nbTocPages'] = TocPages(extract_as_dict).getNbPages() else: - if print_config.get('general_toc_length') and int(print_config.get('general_toc_length')) > 0: - extract_as_dict['nbTocPages'] = print_config.get('general_toc_length', 2) + if print_config.get('expected_toc_length') and int(print_config.get('expected_toc_length')) > 0: + extract_as_dict['nbTocPages'] = print_config.get('expected_toc_length') else: extract_as_dict['nbTocPages'] = 1 @@ -119,7 +119,7 @@ def __call__(self, value, system): data=json.dumps(spec) ) try: - log.debug('Validation of the TOC length with compute_toc_pages set to {} and general_toc_length set to {}'.format(print_config.get('compute_toc_pages'), print_config.get('general_toc_length'))) # noqa + log.debug('Validation of the TOC length with compute_toc_pages set to {} and expected_toc_length set to {}'.format(print_config.get('compute_toc_pages'), print_config.get('expected_toc_length'))) # noqa with io.BytesIO() as pdf: pdf.write(print_result.content) pdf_reader = PdfReader(pdf) diff --git a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml index 6189143f97..027758c227 100644 --- a/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml +++ b/tests/contrib.print_proxy.mapfish_print/resources/test_config.yml @@ -5,7 +5,7 @@ pyramid_oereb: TRANSPARENT: 'true' OTHERCUSTOM: 'myvalue' compute_toc_pages: false - general_toc_length: 2 + expected_toc_length: 2 theme: source: diff --git a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py index cab5ea78c3..9066a8050b 100644 --- a/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py +++ b/tests/contrib.print_proxy.mapfish_print/test_mapfish_print_configuration.py @@ -106,8 +106,8 @@ def test_toc_pages_default_config(): Config._config = None Config.init('./tests/contrib.print_proxy.mapfish_print/resources/test_config.yml', 'pyramid_oereb') compute_toc_pages = Config.get('print', {}).get('compute_toc_pages') - general_toc_length = Config.get('print', {}).get('general_toc_length') + expected_toc_length = Config.get('print', {}).get('expected_toc_length') assert isinstance(compute_toc_pages, bool) assert bool(compute_toc_pages) is False - assert general_toc_length == 2 + assert expected_toc_length == 2