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

Expose all resources on a service resource. #60

Merged
merged 5 commits into from
Feb 10, 2015

Conversation

danielgtaylor
Copy link
Member

This change brings back behavior that was removed in Boto 3 - 0.0.7
and allows things like the following to work again:

import boto3

s3 = boto3.resource('s3')
obj = s3.Object('bucket-name', 'key')

This is required to gain direct access to some resources that are not exposed as subresources nor references (think something like sqs.Message, which you can now only get from sqs.Queue('url').receive_messages() => [Message(...)] Without the change in this pull request there is no way to instantiate a message instance yourself).

cc @jamesls @kyleknap

This change brings back behavior that was removed in Boto 3 - 0.0.7
and allows things like the following to work again:

```python
import boto3

s3 = boto3.resource('s3')
obj = s3.Object('bucket-name', 'key')
```
@danielgtaylor danielgtaylor added the bug This issue is a confirmed bug. label Feb 9, 2015
@danielgtaylor danielgtaylor self-assigned this Feb 9, 2015
allows things like ``s3.Object('bucket-name', 'key')`` to
work even though the JSON doesn't define it explicitly.

@rtype: dict
Copy link
Contributor

Choose a reason for hiding this comment

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

What's with the @rtype: notation?

It is possible to define many subresources on a service that have the same
resource type, e.g. `Queue`, `PriorityQueue`, and `Stack` might all be
implemented as a single resource type with different default values.
We need to make sure all of these are exposed on the service resource.
if has_def.get('resource', {}).get('type') == name:
definition[has_name] = has_def
break
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this else coming from? It does not look in line with any if statement.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's from the for loop. If it never breaks, then the else is executed. I've since removed it to simplify the code and fix a potential case I hadn't considered so it should now be easier to understand.

@kyleknap
Copy link
Contributor

kyleknap commented Feb 9, 2015

Looks good. 🚢 Thanks for fixing the comments I made earlier

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e2d3706 on service-subresources into * on develop*.

@kyleknap
Copy link
Contributor

Thanks! 🚢

danielgtaylor added a commit that referenced this pull request Feb 10, 2015
Expose all resources on a service resource.
@danielgtaylor danielgtaylor merged commit d4ce4f9 into develop Feb 10, 2015
@danielgtaylor danielgtaylor deleted the service-subresources branch February 10, 2015 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants