Skip to content

Commit

Permalink
Fixed an issue in search and replace (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
duchenean authored Oct 15, 2024
1 parent d7b3cc1 commit 347f550
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Changelog
3.44 (unreleased)
-----------------

- Nothing changed yet.

- Fixed an issue when odt_file.filename could be None when searching and replacing - backport from 4.x.
[aduchene]

3.43 (2024-04-10)
-----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, podtemplates):

# compute the (future) file system path of the plone pod templates
for podtemplate in podtemplates:
if not podtemplate.odt_file:
if not podtemplate.odt_file or not podtemplate.odt_file.filename:
continue # ignore templates referring another pod template.
file_extension = podtemplate.odt_file.filename.split(".")[-1].lower()
template_path = get_site_root_relative_path(podtemplate)
Expand Down
8 changes: 8 additions & 0 deletions src/collective/documentgenerator/tests/test_search_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,11 @@ def test_search_replace_control_panel_regex_validator(self):
data = {"replacements": replacements}
errors = form.widgets.validate(data)
self.assertFalse(errors)

def test_no_odt_file_or_no_filename(self):
self.template1.odt_file = None
self.template2.odt_file.filename = None
with SearchAndReplacePODTemplates((self.template1, self.template2)) as search_replace:
results = search_replace.search("view")

self.assertEqual(len(results.keys()), 0)

0 comments on commit 347f550

Please sign in to comment.