From cc51c312b0e07377b22579f16b926990c3bcac82 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Sun, 15 Sep 2024 13:55:51 -0500 Subject: [PATCH] Give the requested search_path to the html template --- src/pgwui_sql/templates/sql.mak | 1 + src/pgwui_sql/views/sql.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/pgwui_sql/templates/sql.mak b/src/pgwui_sql/templates/sql.mak index 4f296d3..b5bc5a4 100644 --- a/src/pgwui_sql/templates/sql.mak +++ b/src/pgwui_sql/templates/sql.mak @@ -23,6 +23,7 @@ This template uses the following variables in it's context: + search_path The requested search_path sql Text of the sql command(s) result_rows List of SQLResult objects diff --git a/src/pgwui_sql/views/sql.py b/src/pgwui_sql/views/sql.py index d6e252a..d2a79d4 100644 --- a/src/pgwui_sql/views/sql.py +++ b/src/pgwui_sql/views/sql.py @@ -79,12 +79,17 @@ class SQLResultsHandler(pgwui_core.core.SessionDBHandler): cur ''' sql_results = attrs.field(factory=list) + search_path = attrs.field(default=None) def make_form(self): return pgwui_sql.views.base.SQLForm().build( self, ip=pgwui_sql.views.base.SQLInitialPost(), fc=pgwui_sql.views.base.SQLWTForm) + def read(self): + super().read() + self.search_path = self.request.POST.get('search_path') + def write(self, result, errors): ''' Setup dict to render resulting html form @@ -96,6 +101,7 @@ class SQLResultsHandler(pgwui_core.core.SessionDBHandler): report_success Boolean. Whether the copy succeeded. ''' response = super().write(result, errors) + response['search_path'] = self.search_path response['report_success'] = (not response['errors'] and self.uf['action'] != '') return response -- 2.34.1