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

Modifying read_config to only look for a pyrax specific config section #346

Closed
elliott-davis opened this issue Apr 11, 2014 · 2 comments
Closed

Comments

@elliott-davis
Copy link

I am implementing pyrax in a larger project and would like to be able to use a single config file to run the project and pyrax. I noticed that in read_config there is a for loop iterating each of the sections and looking of values in each. This causes a lot of problems when more than on section is defined. When Identity type isn't defined in each section you get a None back which causes _id_type to fail.

I have two proposed solutions that I would like to open up for discussion.

  1. Only look for a dedicated pyrax section.
    or
  2. Add a default value of "rackspace" to the safe_get call.

The first is more appealing to me but I don't want to submit a patch and have it break existing functionality. Is there a reason there is a for loop over each of the sections?

@EdLeafe
Copy link
Contributor

EdLeafe commented Apr 17, 2014

Sorry for taking so long to respond; I was away at PyCon.

Specifying the identity type being used is a fundamental requirement for a configuration, and not having defined should be an error. But I agree that it should only raise the error if the configuration is used. I saw your PR, and I think the solution is much simpler than what you propose.

EdLeafe added a commit that referenced this issue Apr 17, 2014
Previously, any section missing the 'identity_type' definition would
cause pyrax to raise an exception on startup. Now it will only raise an
exception if you attempt to use the environment defined in that section.
This addresses GitHub #346.
@elliott-davis
Copy link
Author

I agree that my solution was a bit overwrought for the problem mentioned. I do think that there were some good parts to the patch. Specifically, not having read config traverse every section of the config file. Also, having the ability to specify the config file. It would be very helpful to embed the pyrax config in a more general application config.

I would be happy to file new issues against these and fix up the code from this patch to be satisfactory. Let me know what you think.

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

No branches or pull requests

2 participants