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

load application from factory function #2178

Merged
merged 3 commits into from Nov 19, 2019
Merged

load application from factory function #2178

merged 3 commits into from Nov 19, 2019

Conversation

davidism
Copy link
Contributor

@davidism davidism commented Nov 17, 2019

Use ast.parse to validate that the string passed to the CLI is either an attribute name or a function call. Use ast.literal_eval to parse positional and keyword arguments to the function. Call the function to get the real application.

fixes #2159

Todo:

  • tests
  • docs
  • changelog

Use `ast.parse` to validate that the string passed to the CLI is either
an attribute name or a function call. Use `ast.literal_eval` to parse
any positional and keyword arguments to the function. Call the function
to get the real application.

Co-authored-by: Connor Brinton <connor.brinton@gmail.com>
@davidism
Copy link
Contributor Author

@benoitc I was going to add a news entry, but couldn't figure out where to add it. There's no section for the next 20.x version, and the news.rst file doesn't link to PRs, while the news-2018.rst file does. Let me know what you want, or you can just push to this branch.

@davidism davidism marked this pull request as ready for review November 17, 2019 19:47
@benoitc benoitc added this to the 20.0.1 milestone Nov 18, 2019
@benoitc benoitc self-assigned this Nov 18, 2019
@benoitc
Copy link
Owner

benoitc commented Nov 18, 2019

sounds good for me. I will do some tests this afternoon. Thanks for the patch!

@benoitc benoitc merged commit e764acc into benoitc:20.x Nov 19, 2019
benoitc added a commit that referenced this pull request Nov 19, 2019
benoitc pushed a commit that referenced this pull request Nov 19, 2019
* load application from factory function

Use `ast.parse` to validate that the string passed to the CLI is either
an attribute name or a function call. Use `ast.literal_eval` to parse
any positional and keyword arguments to the function. Call the function
to get the real application.

Co-authored-by: Connor Brinton <connor.brinton@gmail.com>

* test coverage for util.import_app

* document app factory pattern
@davidism davidism deleted the import-factory branch November 20, 2019 21:42
@tilgovi
Copy link
Collaborator

tilgovi commented Nov 21, 2019

Thank you so much for the help on this.

@benoitc
Copy link
Owner

benoitc commented Nov 21, 2019

@davidism sorry I missed your message. The changes should be added to https://github.com/benoitc/gunicorn/blob/master/docs/source/news.rst

also I don't link anymore to issues or ids now since it makes the changes history too much dependent of Github. So a change is a line describing the change. Rest of the history must be in git :)

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.

None yet

3 participants