From 2b9e0e19a254d1597b7a0aa504d043726f4cb7aa Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Thu, 2 Oct 2025 18:20:31 +1000 Subject: [PATCH] add a to_dict() for States, and then I can use a 1-liner to set a var in jscript --- states.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/states.py b/states.py index 96f6dc0..0cc40e5 100644 --- a/states.py +++ b/states.py @@ -28,7 +28,7 @@ class PA_UserState(db.Model): root = db.Column(db.String, unique=False, nullable=False ) cwd = db.Column(db.String, unique=False, nullable=False ) search_term = db.Column(db.String, unique=False, nullable=False ) - + def __repr__(self): return f"" @@ -85,9 +85,13 @@ class States(PA): self.default_folder_noo=u.default_storage_noo self.default_search_noo=u.default_search_noo self.cwd=self.root - return + def to_dict(self): + # Automatically include all instance attributes + return {key: value for key, value in vars(self).items()} + + ################################################################################ # /states -> GET only -> prints out list of all prefs (simple for now) ################################################################################