Give the requested search_path to the html template
authorKarl O. Pinc <kop@karlpinc.com>
Sun, 15 Sep 2024 18:55:51 +0000 (13:55 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Sun, 15 Sep 2024 18:55:51 +0000 (13:55 -0500)
src/pgwui_sql/templates/sql.mak
src/pgwui_sql/views/sql.py

index 4f296d3394dcbd7a4dc3c1e1ba32604cdbea90ea..b5bc5a46990c02751d2f1f25bdbd97df1771e2c6 100644 (file)
@@ -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
 </%doc>
index d6e252a61519988c1cab0fef5ed1001f02337865..d2a79d4f62a68266bb13f3e42cf16d2b7a515769 100644 (file)
@@ -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