Skip to content

Add CursorPagination, enhance test client to handle client.post better #322

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

Closed
wants to merge 2 commits into from

Conversation

erichaus
Copy link

@erichaus erichaus commented Feb 6, 2017

Opening this preemptively for discussion:

Aside from adding a cursor paginator I think we need to address an issue that was already brought up by @abdulhaq-e and others where testing code that uses this package will break on APITestClient().post as discussed here #275

Will resolve #321 and #320

@eriktrom
Copy link

eriktrom commented Feb 6, 2017

👍

@erichaus erichaus changed the title Add CursorPagination, add pagination to docs, fix renderer_context issue Add CursorPagination, enhance test client to handle client.post better Feb 6, 2017
@@ -396,7 +396,7 @@ def build_json_resource_obj(cls, fields, resource, resource_instance, resource_n
resource_data.append(('links', {'self': resource[api_settings.URL_FIELD_NAME]}))
return OrderedDict(resource_data)

def render_relationship_view(self, data, accepted_media_type=None, renderer_context=None):
def render_relationship_view(self, data, accepted_media_type=None, renderer_context={}):
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a mutable default parameter is generally a bad idea in python, due to:

Python's default arguments are evaluated once when the function is defined, not each time the function is called (like it is in say, Ruby). This means that if you use a mutable default argument and mutate it, you will and have mutated that object for all future calls to the function as well.

more details

Copy link
Author

Choose a reason for hiding this comment

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

@santiavenda2 fair point, I guess this package needs to add better exception handling then since right off the bat if renderer_context is the default of None, the first line of code will fail. We're looking at other options though as this package lacks documentation and doesn't appear to be active anymore. The added complexity layer on top of DRF which is on top of Django just makes it very hard to deal with.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this mean you're ok closing this PR? This comment makes it seem to me like this is not important to you anymore, but I might be misreading. I'm wondering if I should spend the time to review or not.

@erichaus erichaus closed this Feb 22, 2017
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.

4 participants