Skip to content

Conversation

@florianschieder
Copy link

this prevents aldryn_forms' initialization from failing with 'RuntimeError: dictionary size changed during iteration' in certain existing codebases still running under django CMS 3.

Installing this branch into our codebase and testing our existing forms worked properly.

this prevents aldryn_forms' initialization from failing with
'RuntimeError: dictionary size changed during iteration' in certain
existing codebases still running under django CMS 3.
@zbohm
Copy link
Collaborator

zbohm commented Apr 22, 2025

I'm sorry, but Aldryn forms do not support django-cms versions earlier than 3.11. The AliasPlugin was added in version 3.0.3.

In addition, moving the import to the body of the functions as proposed here would cause the import failure to occur later than when the project starts, which is not wanted. The proper approach is to raise an exception as soon as possible.

@florianschieder
Copy link
Author

Please excuse the misleading description, "still running under v3" was intended as "still running django-cms < 4"...
Translating german sayings into English word by word was a dumb idea. ;)

We are using django-cms == 3.11, so the problem I faced was not an ImportError. With my experiences with django-cms based systems, importing cms_plugins within the module models itself (or transitively via other modules) causes the plugin pool to be populated before the regular django-cms plugin initialization. This is the state without the proposed fix, which IMHO then causes the "dictionary size changed during iteration" error in django-cms' template validation routine.

I anyway must admit I did not fully trace the circumstances which caused the RuntimeError: dictionary size changed during iteration failure. Debugging made me assume it might have been an early import issue within aldryn_forms itself against certain Django-CMS versions.

I'm fine with having this pull request rejected anyway if you think this is not a reasonable solution.

@zbohm
Copy link
Collaborator

zbohm commented Apr 22, 2025

It seems to me that you are trying to cover up the effects of the problem rather than addressing the real cause of the problem. To really assess this, I would need some sort of user case to raise the exception you describe.

@florianschieder
Copy link
Author

You are right, I cannot reproduce it with a clean aldryn-forms & django-cms setup. I could find out the minimal amount of our internal django apps, leaving them commented out fixes the issue.

I'm still curious about what's happening here but I'm now certain this issue is not related to aldryn-forms itself and will investigate further on our side. Many thanks anyway for your time.

For sake of completeness here I'll attach a subset of the error:

 [..]
   File "/usr/local/lib/python3.12/site-packages/cms/utils/setup.py", line 54, in setup
     plugin_pool.validate_templates()
   File "/usr/local/lib/python3.12/site-packages/cms/plugin_pool.py", line 58, in validate_templates
     for plugin in plugins:
                   ^^^^^^^
 RuntimeError: dictionary changed size during iteration

@zbohm
Copy link
Collaborator

zbohm commented Oct 21, 2025

The issue was resolved by merging pull request #5. Released in version 8.3.0.

@zbohm zbohm closed this Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants