[refactor] Remove late setting of database_connection in SessionManager#4976
Merged
Conversation
During server initialization, there is a period when SessionManager's __database_connection property is None, and eventually this property is set to a proper sessionmaker object in the __init__ function of the CCSimpleHttpServer class. Due to this structure, it became a common pattern in the SessionManager class to add "if __database_connection" guards in the beginning of multiple functions to handle the case where the __database_connection property is still None. In this refactor, the SessionManager object is now constructed properly with a "__database_connection". That field name was also misleading, therefore it was renamed to __config_db_sessionmaker. This change required to now construct the SessionManager object in the __init__ method of the server class, and unfortunately, it increased the number of parameters of its constructor. Hopefully this makes the further refactoring goal easier to separate server configuration handling from the SessionManager class.
bruntib
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
During server initialization, there is a period when SessionManager's __database_connection property is None, and eventually this property is set to a proper sessionmaker object in the init function of the CCSimpleHttpServer class.
Due to this structure, it became a common pattern in the SessionManager class to add "if __database_connection" guards in the beginning of multiple functions to handle the case where the __database_connection property is still None.
In this refactor, the SessionManager object is now constructed properly with a "__database_connection". That field name was also misleading, therefore it was renamed to __config_db_sessionmaker. This change required to now construct the SessionManager object in the init method of the server class, and unfortunately, it increased the number of parameters of its constructor.
Hopefully this makes the further refactoring goal easier to separate server configuration handling from the SessionManager class.