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

Default application_home is not a good general choice #1672

Open
corranwebster opened this issue Jul 21, 2022 · 0 comments
Open

Default application_home is not a good general choice #1672

corranwebster opened this issue Jul 21, 2022 · 0 comments

Comments

@corranwebster
Copy link
Contributor

The name of the application is selected by looking at the enclosing directory of the main script:

def _get_application_dirname(self):
"""
Return the name of the directory (not a path) that the "main"
Python script which started this process resides in, or "" if it could
not be determined or is not appropriate.
For example, if the script that started the current process was named
"run.py" in a directory named "foo", and was launched with "python
run.py", the name "foo" would be returned (this assumes the directory
name is the name of the app, which seems to be as good of an assumption
as any).
"""
dirname = ""
main_mod = sys.modules.get("__main__", None)
if main_mod is not None:
if hasattr(main_mod, "__file__"):
main_mod_file = path.abspath(main_mod.__file__)
dirname = path.basename(path.dirname(main_mod_file))
return dirname

This is often something generic, like app, or when being run in tests is likely to be the name of the test runner (eg. unittest).

The only way to override is to completely override application_home.

Having a property that can be set for the directory name would be very useful.

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

1 participant