Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.0a7 (unreleased)

- Generic setup migration: Migrate any GenericSetup xml files in any location.
This fixes a problem, where upgrade steps were not migrated.
[thet]

## 1.0.0a6 (2026-03-08)

- Replace the plone.app.z3cform relateditems widget with the contentbrowser
Expand Down
10 changes: 3 additions & 7 deletions src/plone_codemod/zcml_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def migrate_genericsetup_files(
config_path: Path = CONFIG_PATH,
dry_run: bool = False,
) -> list[Path]:
"""Walk directory and migrate GenericSetup XML files (profiles/**/*.xml)."""
"""Walk directory and migrate all GenericSetup XML files."""
config = load_config(config_path)

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

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

if dry_run:
try:
Expand Down
13 changes: 8 additions & 5 deletions tests/test_zcml_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,17 @@ def test_migrate_genericsetup_files_in_profiles(self, config):
content = xml_file.read_text()
assert "plone.base.interfaces.controlpanel.IEditingSchema" in content

def test_skips_non_profile_xml(self, config):
"""XML files outside profiles/ directories should be skipped."""
def test_migrate_genericsetup_files_in_other_locations(self, config):
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
xml_file = root / "random.xml"
profiles = root / "other"
profiles.mkdir(parents=True)
xml_file = profiles / "resources.xml"
xml_file.write_text(
'<records interface="Products.CMFPlone.interfaces.controlpanel.IEditingSchema" />'
'<records interface="Products.CMFPlone.interfaces.IBundleRegistry" />'
)

modified = migrate_genericsetup_files(root)
assert len(modified) == 0
assert len(modified) == 1
content = xml_file.read_text()
assert "plone.base.interfaces.resources.IBundleRegistry" in content
Loading