Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

API Changes #3774

Merged
merged 6 commits into from Dec 17, 2018
Merged

API Changes #3774

merged 6 commits into from Dec 17, 2018

Conversation

dralley
Copy link
Contributor

@dralley dralley commented Nov 27, 2018

These are the API changes from the single-table-content work that were discussed.

@pep8speaks
Copy link

pep8speaks commented Nov 27, 2018

Hello @dralley! Thanks for updating the PR.

Comment last updated on December 14, 2018 at 19:58 Hours UTC

@@ -247,6 +247,20 @@ def content(self):
)
return Content.objects.filter(version_memberships__in=relationships)

@property
def content_by_type(self):
Copy link
Contributor Author

@dralley dralley Nov 27, 2018

Choose a reason for hiding this comment

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

I'm not actually sure this function (content_by_type) is necessary or even particularly useful, I may remove it before merging. It seemed like an obvious thing to have at first but I realized that I can't think of anywhere it would actually be used. Generic code doesn't usually need to touch the content-specific fields, so it can just use Content objects. Plugin code already knows what concrete models exist so it can just manage those directly also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should the added() and removed() methods be made properties, to match content? Or should we make content a method? The latter would provide maximal flexibility in terms of being able to add functionality later on in the form of kwargs.

@dralley dralley force-pushed the api-changes branch 13 times, most recently from f8b232a to 51e216d Compare November 28, 2018 21:33
@@ -247,6 +249,62 @@ def content(self):
)
return Content.objects.filter(version_memberships__in=relationships)

@property
Copy link
Contributor Author

@dralley dralley Nov 28, 2018

Choose a reason for hiding this comment

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

These 3 properties are probably temporary, pending a better solution. This is ugly but it was fairly simple for an initial implementation.

If anyone has suggestions on how to do this in a way that better respects separation of responsibilities, please let me know :) It probably isn't something we want to leave in the model layer.

@dralley dralley changed the title API Changes [WIP] API Changes Nov 28, 2018
_content_href = NestedIdentityField(
view_name='versions-content',
lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'},
_content = serializers.DictField(
Copy link
Contributor Author

@dralley dralley Nov 29, 2018

Choose a reason for hiding this comment

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

Are these names OK or should we go back to what they were before?

Different variants:

  • "added_content"
  • "content_added_hrefs"
  • "added_content_hrefs"
  • "added_hrefs"

Copy link
Member

Choose a reason for hiding this comment

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

I prefer the "added_content" and "removed_content".

@@ -244,35 +177,6 @@ class Meta:
class Meta:
fields = ModelSerializer.Meta.fields + ('type',)

def to_representation(self, instance):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be removed since we're no longer trying to serialize generic Content objects as their detail counterparts. Yay!

_removed_href = NestedIdentityField(
view_name='versions-removed-content',
lookup_field='number', parent_lookup_kwargs={'repository_pk': 'repository__pk'},
_content_removed = serializers.DictField(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume the permanent solution to the aforementioned separation of concerns issue will be to make custom field types with the same logic as the properties, but I haven't done this yet and want to field suggestions first. This way was more straightforwards.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that custom fields would be appropriate here.

@@ -1,10 +1,16 @@
from .base import AsyncRemoveMixin, AsyncUpdateMixin, BaseFilterSet, NamedModelViewSet # noqa
# These need to be imported prior to ContentViewSet - do not shuffle this by alphabetical order
from .custom_filters import ( # noqa
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I struggled a little bit with circular imports here -- should we just move these to viewsets.content since they're only used in that one place?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a problem with moving them there.

@@ -60,3 +63,101 @@ class IsoDateTimeFilter(DateTimeFilter):
def __init__(self, *args, **kwargs):
kwargs.setdefault('help_text', _('ISO 8601 formatted dates are supported'))
super().__init__(*args, **kwargs)


class RepoVersionHrefFilter(Filter):
Copy link
Contributor Author

@dralley dralley Dec 3, 2018

Choose a reason for hiding this comment

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

Should I rename this to "BaseRepoVersionHrefFilter" since it's meant to be subclassed and not used directly?

I don't much like the naming of these, generally. Naming suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

The current name seems fine. The not implemented on filter() will let a developer know not to use it directly.

@@ -110,13 +110,13 @@ def test_02_sync_content(self):

self.assertIsNotNone(repo['_latest_version_href'])

content = get_content(repo)
content = get_file_content(repo)
Copy link
Contributor Author

@dralley dralley Dec 3, 2018

Choose a reason for hiding this comment

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

As mentioned on the pulp_file PR, we could just always do get_content(repo)['file'] instead. Open to changing this if QE would prefer it that way.

dralley added a commit to dralley/pulp_file that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_file that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_file that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_file that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_file that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_rpm that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_rpm that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_rpm that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_rpm that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_file that referenced this pull request Dec 17, 2018
@dralley dralley merged commit 28a0f2e into pulp:master Dec 17, 2018
@dralley dralley deleted the api-changes branch December 17, 2018 21:52
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_ansible that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_ansible that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_ansible that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 17, 2018
dralley added a commit to dralley/pulp_python that referenced this pull request Dec 18, 2018
daviddavis pushed a commit to daviddavis/pulp_file that referenced this pull request May 14, 2019
daviddavis pushed a commit to daviddavis/pulp_file that referenced this pull request May 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
7 participants