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

Issue 479: Edited api.content.get_view for increased efficiency to get views #528

Merged

Conversation

samriddhi99
Copy link
Contributor

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

@mister-roboto
Copy link

@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

@mister-roboto
Copy link

@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:

@jenkins-plone-org please run jobs

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!

@samriddhi99
Copy link
Contributor Author

@jenkins-plone-org please run jobs

src/plone/api/content.py Outdated Show resolved Hide resolved
src/plone/api/content.py Outdated Show resolved Hide resolved
@mister-roboto
Copy link

@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

@gforcada
Copy link
Sponsor Member

gforcada commented Feb 4, 2024

@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

views="\n".join(sorted(available_view_names)),
),
)
return adapter
Copy link
Sponsor Member

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? 🤔

Copy link
Member

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.

@stevepiercy
Copy link
Contributor

@gforcada it appears @samriddhi99 was approved and added to the Contributors team after mister-roboto sent the reminder.

@stevepiercy
Copy link
Contributor

stevepiercy commented Feb 4, 2024

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 agreements@plone.org, copying and pasting a link to this issue in reference to this issue.

),
try:
adapter = getMultiAdapter((context, request), name=name)
except Exception:
Copy link
Member

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.

Copy link
Contributor Author

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.

views="\n".join(sorted(available_view_names)),
),
)
return adapter
Copy link
Member

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.

Copy link
Member

@ale-rt ale-rt left a 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!

src/plone/api/content.py Outdated Show resolved Hide resolved
src/plone/api/content.py Outdated Show resolved Hide resolved
@samriddhi99
Copy link
Contributor Author

@stevepiercy
The plone contributors agreement verifier check has passed, so I think the issue has been resolved.

@stevepiercy
Copy link
Contributor

@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)

@samriddhi99
Copy link
Contributor Author

@jenkins-plone-org please run jobs

src/plone/api/content.py Outdated Show resolved Hide resolved
Co-authored-by: Alessandro Pisa <alessandro.pisa@gmail.com>
Copy link
Sponsor Member

@davisagli davisagli left a 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!

@davisagli davisagli merged commit 3565a0b into plone:master Feb 8, 2024
6 of 10 checks passed
mister-roboto pushed a commit to plone/buildout.coredev that referenced this pull request Feb 8, 2024
Branch: refs/heads/master
Date: 2024-01-29T23:26:21+05:30
Author: Samriddhi Singh (samriddhi99) <samriddhisingh6079@gmail.com>
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) <samriddhisingh6079@gmail.com>
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) <samriddhisingh6079@gmail.com>
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) <samriddhisingh6079@gmail.com>
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) <david@glicksoftware.com>
Commit: plone/plone.api@2e80155

Update src/plone/api/content.py

Co-authored-by: Alessandro Pisa &lt;alessandro.pisa@gmail.com&gt;

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) <david@glicksoftware.com>
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
mister-roboto pushed a commit to plone/buildout.coredev that referenced this pull request Feb 8, 2024
Branch: refs/heads/master
Date: 2024-01-29T23:26:21+05:30
Author: Samriddhi Singh (samriddhi99) <samriddhisingh6079@gmail.com>
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) <samriddhisingh6079@gmail.com>
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) <samriddhisingh6079@gmail.com>
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) <samriddhisingh6079@gmail.com>
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) <david@glicksoftware.com>
Commit: plone/plone.api@2e80155

Update src/plone/api/content.py

Co-authored-by: Alessandro Pisa &lt;alessandro.pisa@gmail.com&gt;

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) <david@glicksoftware.com>
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
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.

Speed up api.content.get_view
6 participants