From 8e039ed3a18e88d345343c8ddc0b97dcf7e09721 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 5 Aug 2024 11:59:54 -0500 Subject: [PATCH] Fix double-upload test by handling boolean post values --- src/pgwui_core/core.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pgwui_core/core.py b/src/pgwui_core/core.py index b2f720a..499d29a 100644 --- a/src/pgwui_core/core.py +++ b/src/pgwui_core/core.py @@ -209,6 +209,16 @@ class LoadedForm(collections.abc.MutableMapping): def __delitem__(self, key): del self._store[key] + def booleanize_post(self, post, key): + '''The key, if present, is a boolean value. But post data + is all strings. Convert the post data to a Python boolean. + ''' + if key in post: + if post[key] == 'False': + post[key] = False + else: + post[key] = True + def read_post_and_session(self, post, session, key): '''Read an attribute into self, from either POST or the session, and synchronize the session with the POST value when there is a POST @@ -440,6 +450,7 @@ class UploadFileForm(AuthLoadedForm): # Other POST variables involving a file post = self.uh.request.POST session = self.uh.request.session + self.booleanize_post(post, 'db_changed') if not self.read_post_and_session(post, session, 'db_changed'): self['db_changed'] = False self['filename'] = '' -- 2.34.1