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

Avoid collisions between plugin models #259

Merged
merged 1 commit into from Aug 19, 2019

Conversation

fao89
Copy link
Member

@fao89 fao89 commented Aug 9, 2019

Making mandatory declaring default_related_name
closes #4681

https://pulp.plan.io/issues/4681

NOTE: DO NOT MERGE UNTIL AUGUST 19, 2019

@codecov
Copy link

codecov bot commented Aug 9, 2019

Codecov Report

Merging #259 into master will decrease coverage by 1.01%.
The diff coverage is 92.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #259      +/-   ##
==========================================
- Coverage    67.6%   66.59%   -1.02%     
==========================================
  Files          69       69              
  Lines        3260     3272      +12     
==========================================
- Hits         2204     2179      -25     
- Misses       1056     1093      +37
Impacted Files Coverage Δ
pulpcore/app/models/base.py 76.92% <92.3%> (+3.33%) ⬆️
pulpcore/app/models/fields.py 78.94% <0%> (-15.79%) ⬇️
pulpcore/content/handler.py 47.87% <0%> (-14.9%) ⬇️
pulpcore/app/files.py 66.66% <0%> (-12.13%) ⬇️
pulpcore/app/serializers/task.py 98.55% <0%> (-1.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dcaf70f...75f7916. Read the comment docs.

@@ -0,0 +1 @@
Avoid collisions between plugin models.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for user-facing changelog IMO, but we need something for plugin writers that indicates that this is a breaking change. One solution would be adding a .feature CHANGE pointing to this issue in pulp/pulpcore-plugin#119

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though there are no code changes to pulpcore-plugin, adding a 4681.feature to pulpcore-plugin's changelog makes sense to me. I think this would be a great way to document changes to the plugin API.

cc @bmbouter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daviddavis I agree, even though the changes occur here, we should represent this in the pulpcore-plugin release notes instead. I think of the changelog for pulpcore as the changelog for end users, and the changelog for pulpcore-plugin as the changelog for plugin writers.

@asmacdo, I don't think end-users will understand 4681.feature for the reasons above. For that reason removing 4681.feature and keeping 4681.bugfix make the most sense to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this file to 4681.misc then?

class MasterModelMeta(ModelBase):
def __new__(cls, name, bases, attrs, **kwargs):
"""Override __new__ to set the default_related_name."""
if Model not in bases and MasterModel not in bases:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explicitly stating that this only affects "detail" models?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

abstract = getattr(meta, "abstract", None)

if not default_related_name and not abstract:
raise Exception(_("The default_related_name option has not been set for "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put single quotes around default_related_name so it's clearer for the user?

@@ -0,0 +1,2 @@
Breaking change on how to subclass Master/Detail models in plugins.
Please refer to https://github.com/pulp/pulpcore-plugin/pull/119
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can drop this file based on the above conversation.

Making mandatory declaring default_related_name
Required PR: pulp/pulp_file#269
Required PR: pulp/pulp-certguard#27
closes #4681
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

4 participants