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

Copy wrapped resource's attributes into the service #544

Merged
merged 1 commit into from
Sep 1, 2020
Merged

Copy wrapped resource's attributes into the service #544

merged 1 commit into from
Sep 1, 2020

Conversation

jimmy-lt
Copy link

When a Service is generated from a Resource, it losses all the attributes from the resource (specifically the docstring). This change ensures that the wrapping service looks like it wrapped resource.

This is particularly useful since when I list the services registered by Cornice (config.registry.cornice_services), I need to have access to the original docstring.

Since the service is based on the resource, it makes also sense to mimic its attributes.

Copy link
Contributor

@leplatrem leplatrem left a comment

Choose a reason for hiding this comment

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

Thanks!

Could you please add a test?

Update the generated service to look like the resource it is wrapping.
@jimmy-lt
Copy link
Author

jimmy-lt commented Sep 1, 2020

Added a test case, let me know if that works for you.

(x.name, x) for x in self.config.registry.cornice_services.values()
if x.name in resources
):
for attr in functools.WRAPPER_ASSIGNMENTS:
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL WRAPPER_ASSIGNMENTS :) 👍

@leplatrem leplatrem merged commit 4f56c9c into Cornices:master Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants