diff --git a/python/ccdb/provider.py b/python/ccdb/provider.py index c170a1f..0f59b2a 100644 --- a/python/ccdb/provider.py +++ b/python/ccdb/provider.py @@ -298,10 +298,21 @@ def create_directory(self, new_dir_name, parent_dir_or_path, comment=""): return directory def get_directory_by_id(self, dir_id): - return self.session.query(Directory).filter(Directory.id == dir_id).one() + self._ensure_dirs_loaded() + return self.dirs_by_id[dir_id] def get_type_table_by_id(self, table_id): - return self.session.query(TypeTable).filter(TypeTable.id == table_id).one() + type_table = self.session.query(TypeTable).filter(TypeTable.id == table_id).one() + assert isinstance(type_table, TypeTable) + + # We set parent_dir here manually because we want to ensure that + # the directory comes after self._ensure_dirs_loaded() is called + # this is important to have all directories correct full paths to be set + # and consequently to have correct full path set for the table!!!!!! + parent_dir = self.get_directory_by_id(type_table.parent_dir_id) + type_table.parent_dir = parent_dir + + return parent_dir # @brief Updates directory # diff --git a/python/ccdb/webgui/__init__.py b/python/ccdb/webgui/__init__.py index 85acc1d..2201fa5 100644 --- a/python/ccdb/webgui/__init__.py +++ b/python/ccdb/webgui/__init__.py @@ -114,6 +114,7 @@ def directory_tree(): @app.route('/get-dir-info/') def get_dir_info(dir_id): db: ccdb.AlchemyProvider = g.db + db._ensure_dirs_loaded() directory = db.get_directory_by_id(dir_id) if not directory: return jsonify({"error": "Directory not found"}), 404 @@ -122,6 +123,7 @@ def get_dir_info(dir_id): @app.route('/get-table-info/') def get_table_info(table_id): db: ccdb.AlchemyProvider = g.db + db._ensure_dirs_loaded() table = db.get_type_table_by_id(table_id) if not table: return jsonify({"error": "Table not found"}), 404