-
Notifications
You must be signed in to change notification settings - Fork 105
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
Adding convenience methods for getting or creating objects #220
base: master
Are you sure you want to change the base?
Conversation
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.
Andrew here (in case you don't recognize the updated username) - looks good to me @gsnyder2007.
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) |
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.
Actually, looking at this again - think there should be more here.
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.
Uh, yeah, makes me wonder how my tests even worked. Investigating....
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.
some code got borked in transit. Fixing...
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.
Pushed an update with the (I think) now complete code. Still testing....
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.