Adding convenience methods for getting or creating objects#220
Open
gsnyder2007 wants to merge 4 commits intomasterfrom
Open
Adding convenience methods for getting or creating objects#220gsnyder2007 wants to merge 4 commits intomasterfrom
gsnyder2007 wants to merge 4 commits intomasterfrom
Conversation
OffBy0x01
approved these changes
Sep 12, 2022
Collaborator
OffBy0x01
left a comment
There was a problem hiding this comment.
Andrew here (in case you don't recognize the updated username) - looks good to me @gsnyder2007.
OffBy0x01
requested changes
Sep 13, 2022
blackduck/Client.py
Outdated
| return filtered[0] if filtered else None | ||
|
|
||
| def get_or_create_resource(self, field, value, name, parent=None, **kwargs): | ||
| resource = self.get_resource_by(field, value, name, parent, **kwargs) |
Collaborator
There was a problem hiding this comment.
Actually, looking at this again - think there should be more here.
Contributor
Author
There was a problem hiding this comment.
Uh, yeah, makes me wonder how my tests even worked. Investigating....
Contributor
Author
There was a problem hiding this comment.
some code got borked in transit. Fixing...
Contributor
Author
There was a problem hiding this comment.
Pushed an update with the (I think) now complete code. Still testing....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finally getting back to providing these convenience methods for,
@admacdonald1 you will recognize your suggested code for the get_resource_by() method. I've also attempted a get_or_create_by() and have included some sample code that uses it - see crud_project.py, crud_version.py, and update_version_settings.py (all in the .../examples/client folder).
I set the version for this proposal to v1.1.0 since it's a minor improvement to the actual interface (as opposed to a simple fix).
Let me know your thoughts.