Both the file database and the key database are used throughout the app, and both depend on the output of the CommandValidator for instantiation.
Current approach
Both databases use this singleton decorator to make their instance available to all modules like this:
from FileDatabase import FileDatabase
FileDatabase().foo()
Except in app.py, where it's defined like:
FILEDB = None
...
FILEDB = FileDatabase(data_dir)
Cons
We must be careful to instantiate the FileDatabase() with its parameters before any of these calls happen or we'll get a confusing error.
We reference the database in different ways in different modules.
Other approaches
1) Attach to trame state objectstate._filedb = FileDatabase(work_dir) throws error on attempting serialization
2) Inject databases into widgets that need them.
Both the file database and the key database are used throughout the app, and both depend on the output of the CommandValidator for instantiation.
Current approach
Both databases use this singleton decorator to make their instance available to all modules like this:
Except in app.py, where it's defined like:
Cons
We must be careful to instantiate the FileDatabase() with its parameters before any of these calls happen or we'll get a confusing error.
We reference the database in different ways in different modules.Other approaches
1)
Attach to tramestate
objectstate._filedb = FileDatabase(work_dir)
throws error on attempting serialization 2) Inject databases into widgets that need them.