Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extending polymorphic models in plugins #4608

Merged
merged 1 commit into from Aug 31, 2020

Conversation

OmeGak
Copy link
Member

@OmeGak OmeGak commented Aug 27, 2020

Subclassing polymorphic models is not currently allowed from plugins. Example:

class RegistrationFormSessionsSection(RegistrationFormSection):
    __mapper_args__ = {
        'polymorphic_identity': RegistrationFormItemType.section_sessions
    }

Blows up like this:

Exception: Plugin 'un' added a model which is not in a plugin schema ('RegistrationFormSessionsSection' in 'event_registration')

This PR solves it.

@OmeGak OmeGak changed the title Allow polymorphic models in plugins Allow extending polymorphic models from plugins Aug 27, 2020
@OmeGak OmeGak changed the title Allow extending polymorphic models from plugins Allow extending polymorphic models in plugins Aug 27, 2020
indico/core/plugins/__init__.py Outdated Show resolved Hide resolved
@OmeGak OmeGak force-pushed the wip/polymorphic-plugin branch from 242c8c9 to 892214f Compare Aug 27, 2020
@OmeGak OmeGak force-pushed the wip/polymorphic-plugin branch from 892214f to d613395 Compare Aug 27, 2020
Copy link
Member

@ThiefMaster ThiefMaster left a comment

I think our check in _import_models doesn't even work all the time, since usually the model already got imported when loading the plugin.. anyway, for the cases where it does work your change looks reasonable :)

@ThiefMaster ThiefMaster merged commit afaf699 into indico:master Aug 31, 2020
4 checks passed
@ThiefMaster ThiefMaster deleted the wip/polymorphic-plugin branch Aug 31, 2020
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.

None yet

2 participants