Parameterise template server #3
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the configuration and logging setup for the Python template server, centralizing constants, moving logging setup to its own module, and simplifying configuration loading. It also updates related modules to use the new structure and improves code clarity by removing unused properties and parameters.
Configuration and Logging Refactor:
ROOT_DIR,CONFIG_DIR,LOG_DIR, etc.) intopython_template_server/constants.py, making them accessible throughout the codebase. ([python_template_server/constants.pyR3-L19](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-6aafcdb899cb6f32a24c647a60e3684570362c33a5cb8defd81d0a5fde7e8203R3-L19))python_template_server/logging_setup.py, removing logging configuration fromconfig.pyand enabling consistent logging initialization across modules. ([python_template_server/logging_setup.pyR1-R50](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-2a2a395008e0a4989bf47c6c718aedfbcb51092980d48eadea12f354fe077e7aR1-R50))setup_logging()from the new logging setup module, ensuring logging is initialized before any logger usage. ([[1]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-1a98048e39ba4137b669c4f93e1349189a2efe3b816d5740e1b60e98cb364037L10-L16),[[2]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-70cfaa5cac5328039faa54a2c028498b480c8bca19724b7854ed6714675cc0f9L14-R18),[[3]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aR19-R64))Configuration Loading Simplification:
config.pymodule and integrated configuration loading directly into the abstract base classTemplateServervia a newload_configmethod, which loads and validates the config file using centralized constants. ([[1]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-cde0e1bbc865d1b493bfe2fd6bc655319aa2091718577624dfe97fe472ddb94cL1-L112),[[2]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aR77-R106))ExampleServerinmain.pyto use the new configuration loading approach, eliminating the need to pass a config object on initialization. ([[1]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-94db1ccf6dddf805df9b761447b19a02f4ee37174d18e30bf644bf2faf61495eL3-R22),[[2]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-94db1ccf6dddf805df9b761447b19a02f4ee37174d18e30bf644bf2faf61495eL28-R34))Code Cleanup and Consistency:
authentication_handler.pyto use new constants, improving reliability and reducing hardcoded paths. ([python_template_server/authentication_handler.pyL42-R52](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-1a98048e39ba4137b669c4f93e1349189a2efe3b816d5740e1b60e98cb364037L42-R52))models.pyto streamline the configuration models and eliminate unnecessary code. ([[1]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-7bd9896d9e20648c190059b324cad22cac285ffd06e86f8fbb6247cf3e629ba6L9-L10),[[2]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-7bd9896d9e20648c190059b324cad22cac285ffd06e86f8fbb6247cf3e629ba6L29-L33))template_server.pyto use the centralized logger instead of instance loggers, ensuring consistent logging output. ([[1]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aL78-R116),[[2]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aL87-R134),[[3]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aL106-R144),[[4]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aL116-R154),[[5]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aL141-R179),[[6]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aL153-R191),[[7]](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-fc053d43591ac007c7812f0590d7bfab3123bf19b39f520309b52e1c79b3243aL196-R234))Dockerfile Update:
[DockerfileL54-R63](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557L54-R63))Certificate Generation Update:
ExampleServer().config, removing dependency on command-line argument parsing. ([python_template_server/certificate_handler.pyL139-R141](https://github.com/javidahmed64592/python-template-server/pull/3/files#diff-70cfaa5cac5328039faa54a2c028498b480c8bca19724b7854ed6714675cc0f9L139-R141))