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.
Description
Resolves issue #392
Removes
make_session_maker
and now create a global session factory calledSession
in db.py and configure it in app.py.Controller no longer manages the application session; it not longer has a
sessionmaker
or asession
that is accessed by widgets. We no longer need to pass around Sessions in order to share a session across separate sections of code. If we call the global session factory twice we get back the same session.The following changes were also added while working to remove all references to the Controller's session object:
Removes
source_exists
and its one reference inwidgets.py::on_source_changed
since it is unnecessary when we already check if the source widget exists (it will not exists if the source was deleted from the db). This is relevant since this was one of the areas of code that referencedcontroller.session
. Instead of rewriting it and then removing it later, I decided to just remove it.Removes
controller.get_file
and reference to it inFileWidget
constructor since we are now initializingFileWidget
with aFile
object.Moves database operation for adding reply from logic.py to storage.py
Models that have a relationship to other models now pass
lazy='subquery'
when defining their relationships in order to do subquery loading, see https://docs.sqlalchemy.org/en/13/orm/loading_relationships.html#relationship-loading-techniques. This gets used when we passsource.collection
toupdate_conversation
Test Plan