Skip to content

Commit 414eb07

Browse files
committed
Generic setup migration: Migrate any GenericSetup xml files in any location.
This fixes a problem, where upgrade steps were not migrated.
1 parent 81a2e67 commit 414eb07

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.0.0a7 (unreleased)
4+
5+
- Generic setup migration: Migrate any GenericSetup xml files in any location.
6+
This fixes a problem, where upgrade steps were not migrated.
7+
[thet]
8+
39
## 1.0.0a6 (2026-03-08)
410

511
- Replace the plone.app.z3cform relateditems widget with the contentbrowser

src/plone_codemod/zcml_migrator.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def migrate_genericsetup_files(
139139
config_path: Path = CONFIG_PATH,
140140
dry_run: bool = False,
141141
) -> list[Path]:
142-
"""Walk directory and migrate GenericSetup XML files (profiles/**/*.xml)."""
142+
"""Walk directory and migrate all GenericSetup XML files."""
143143
config = load_config(config_path)
144144

145145
# Derive dotted-name replacements from the imports section
@@ -149,15 +149,11 @@ def migrate_genericsetup_files(
149149
view_replacements = config.get("genericsetup", {}).get("view_replacements")
150150

151151
modified = []
152-
# Look for XML files in profiles/ directories and also top-level XML
152+
# Look for all XML files (GenericSetup can be in various locations)
153153
for xml_file in sorted(root.rglob("*.xml")):
154-
# Skip non-GenericSetup files
154+
# Skip ZCML files (they are handled separately)
155155
if ".zcml" in xml_file.suffixes:
156156
continue
157-
# Focus on profiles directories and registry files
158-
parts_str = str(xml_file)
159-
if "profiles" not in parts_str and "registry.xml" not in xml_file.name:
160-
continue
161157

162158
if dry_run:
163159
try:

tests/test_zcml_migrator.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,17 @@ def test_migrate_genericsetup_files_in_profiles(self, config):
178178
content = xml_file.read_text()
179179
assert "plone.base.interfaces.controlpanel.IEditingSchema" in content
180180

181-
def test_skips_non_profile_xml(self, config):
182-
"""XML files outside profiles/ directories should be skipped."""
181+
def test_migrate_genericsetup_files_in_other_locations(self, config):
183182
with tempfile.TemporaryDirectory() as tmpdir:
184183
root = Path(tmpdir)
185-
xml_file = root / "random.xml"
184+
profiles = root / "other"
185+
profiles.mkdir(parents=True)
186+
xml_file = profiles / "resources.xml"
186187
xml_file.write_text(
187-
'<records interface="Products.CMFPlone.interfaces.controlpanel.IEditingSchema" />'
188+
'<records interface="Products.CMFPlone.interfaces.IBundleRegistry" />'
188189
)
189190

190191
modified = migrate_genericsetup_files(root)
191-
assert len(modified) == 0
192+
assert len(modified) == 1
193+
content = xml_file.read_text()
194+
assert "plone.base.interfaces.resources.IBundleRegistry" in content

0 commit comments

Comments
 (0)