-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Issue 479: Edited api.content.get_view for increased efficiency to get views #528
Issue 479: Edited api.content.get_view for increased efficiency to get views #528
Conversation
@samriddhi99 you need to sign the Plone Contributor Agreement to merge this pull request. Learn about the Plone Contributor Agreement: https://plone.org/foundation/contributors-agreement |
@samriddhi99 thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment:
To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
@jenkins-plone-org please run jobs |
@samriddhi99 you need to sign the Plone Contributor Agreement to merge this pull request. Learn about the Plone Contributor Agreement: https://plone.org/foundation/contributors-agreement |
@samriddhi99 thanks for this contribution, hopefully we get all the ticks green ✅ and can merge it soon! 🤩 There is one tick that you need to work on though: the contributor agreement, please read about it and sign it 🤞🏾 https://plone.org/foundation/contributors-agreement |
src/plone/api/content.py
Outdated
views="\n".join(sorted(available_view_names)), | ||
), | ||
) | ||
return adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adapter
here could be not defined, if we get an exception when trying to get the adapter, and thus get into the exception Exception
part of the code and the view name it is found in the available_view_names
.
Could that happen, though? 🤔 A view that you don't have permissions for would get you in such corner case? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The security is not checked when you call getMultiAdapter
, anyway the except Exception
is not good IMO.
@gforcada it appears @samriddhi99 was approved and added to the Contributors team after mister-roboto sent the reminder. |
Something is not quite right. @samriddhi99 was added to the Plone Contributors Team in GitHub, but mister-roboto says otherwise. It's possible that the emails in @samriddhi99's GitHub account do not align with what they put on their Agreement. @samriddhi99 would you please add the email you put on your agreement to your GitHub account? If you already did that, it is possible that there is a typo somewhere, and you should contact [email protected], copying and pasting a link to this issue in reference to this issue. |
src/plone/api/content.py
Outdated
), | ||
try: | ||
adapter = getMultiAdapter((context, request), name=name) | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be except ComponentLookupError
, otherwise you risk to return a wrong message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing it out! I have made the changes accordingly.
src/plone/api/content.py
Outdated
views="\n".join(sorted(available_view_names)), | ||
), | ||
) | ||
return adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The security is not checked when you call getMultiAdapter
, anyway the except Exception
is not good IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I added a couple of suggestions to have micro-optimizations.
Thanks for your contribution!
@stevepiercy |
@samriddhi99 thank you, and I confirm. You're not the only person that experienced a similar issue. After all other checks pass, please read and follow this comment: #528 (comment) |
@jenkins-plone-org please run jobs |
Co-authored-by: Alessandro Pisa <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution!
Branch: refs/heads/master Date: 2024-01-29T23:26:21+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@4b3ef60 Edited api.content.get_view for increased efficiency to get views Files changed: A news/479.internal M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-01T18:41:52+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@f89a207 Changes as per plone/plone.api#528 (comment) have been made Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-05T16:56:47+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@d2715ad Error handling if component not found in function get_view Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-05T17:10:06+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@913b2cd Minor changes to get_view Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-07T21:17:07-08:00 Author: David Glick (davisagli) <[email protected]> Commit: plone/plone.api@2e80155 Update src/plone/api/content.py Co-authored-by: Alessandro Pisa <[email protected]> Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-07T21:21:08-08:00 Author: David Glick (davisagli) <[email protected]> Commit: plone/plone.api@3565a0b Merge pull request #528 from samriddhi99/Issue-479-optimizing-api.content.get_view Issue 479: Edited api.content.get_view for increased efficiency to get views Files changed: A news/479.internal M src/plone/api/content.py
Branch: refs/heads/master Date: 2024-01-29T23:26:21+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@4b3ef60 Edited api.content.get_view for increased efficiency to get views Files changed: A news/479.internal M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-01T18:41:52+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@f89a207 Changes as per plone/plone.api#528 (comment) have been made Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-05T16:56:47+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@d2715ad Error handling if component not found in function get_view Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-05T17:10:06+05:30 Author: Samriddhi Singh (samriddhi99) <[email protected]> Commit: plone/plone.api@913b2cd Minor changes to get_view Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-07T21:17:07-08:00 Author: David Glick (davisagli) <[email protected]> Commit: plone/plone.api@2e80155 Update src/plone/api/content.py Co-authored-by: Alessandro Pisa <[email protected]> Files changed: M src/plone/api/content.py Repository: plone.api Branch: refs/heads/master Date: 2024-02-07T21:21:08-08:00 Author: David Glick (davisagli) <[email protected]> Commit: plone/plone.api@3565a0b Merge pull request #528 from samriddhi99/Issue-479-optimizing-api.content.get_view Issue 479: Edited api.content.get_view for increased efficiency to get views Files changed: A news/479.internal M src/plone/api/content.py
The function does some avoidable check to wake up the view. I have used a try-except block avoid doing the check unless there is an error that pops up.
FIxes #479