Move literal_column_headings setting into PGWUI_Upload
authorKarl O. Pinc <kop@karlpinc.com>
Mon, 31 Aug 2020 20:36:43 +0000 (15:36 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Mon, 31 Aug 2020 21:00:19 +0000 (16:00 -0500)
examples/etc/pgwui.ini
examples/misc/development.ini
src/pgwui_server/__init__.py
src/pgwui_server/exceptions.py
tests/test___init__.py

index 7cb1e4a9788640ed1e89d2bfad46ed67125e8a49..bfe5a4ea9fe8efe0c6b5da2d73b9ce5fd293953d 100644 (file)
@@ -41,14 +41,6 @@ pgwui.default_db = template1
 # Whether or not to change the db content.  (required)
 pgwui.dry_run = False
 
-# Menu presentation
-
-# The PGWUI_Menu component automaticaly constructs a menu for the
-# PGWUI components in use.  The display value of the menu items can
-# be overridden.
-#pgwui.pgwui_upload =
-#    menu_label = upload -- Upload File Into Database
-
 # Routing
 
 # Routes are what call up specific pages.  They are the
@@ -89,6 +81,20 @@ pgwui.dry_run = False
 # vulnerabilties.  Validation is on by default.
 # pgwui.validate_hmac = True
 
+# PGWUI Component Settings
+
+# Menu presentation
+
+# The PGWUI_Menu component automaticaly constructs a menu for the
+# PGWUI components in use.  The display value of the menu items can
+# be overridden using a "menu_label" setting for each component.
+# CAUTION: Do not uncomment the below, instead change the component's
+# "menu_label" setting.
+#pgwui.pgwui_upload =
+#    menu_label = upload -- Upload File Into Database
+
+# pgwui_upload
+
 # Take uploaded column headings literally?
 # The available choices are:
 #   on   The file's column headings, as typed, are the table's column names.
@@ -98,8 +104,9 @@ pgwui.dry_run = False
 #
 # Caution: Non-ASCII column names, particularly in the Turkish locale,
 # are not guaranteed to be case-insensitive.
-pgwui.literal_column_headings = off
-
+pgwui.pgwui_upload =
+    literal_column_headings = off
+    # menu_label = upload -- Upload File Into Database
 
 #
 # Pyramid configuration
index e80eadcea5923ff42739a63f6e7a6fd770718e1b..c613b1b8ecffd1bad2880b78c2f3f22cd7bd50de 100644 (file)
@@ -81,6 +81,20 @@ pgwui.dry_run = False
 # vulnerabilties.  Validation is on by default.
 pgwui.validate_hmac = False
 
+# PGWUI Component Settings
+
+# Menu presentation
+
+# The PGWUI_Menu component automaticaly constructs a menu for the
+# PGWUI components in use.  The display value of the menu items can
+# be overridden using a "menu_label" setting for each component.
+# CAUTION: Do not uncomment the below, instead change the component's
+# "menu_label" setting.
+#pgwui.pgwui_upload =
+#    menu_label = upload -- Upload File Into Database
+
+# pgwui_upload
+
 # Take uploaded column headings literally?
 # The available choices are:
 #   on   The file's column headings, as typed, are the table's column names.
@@ -90,7 +104,9 @@ pgwui.validate_hmac = False
 #
 # Caution: Non-ASCII column names, particularly in the Turkish locale,
 # are not guaranteed to be case-insensitive.
-pgwui.literal_column_headings = off
+pgwui.pgwui_upload =
+    literal_column_headings = off
+    # menu_label = upload -- Upload File Into Database
 
 
 #
index 0b380b33712263eaf9d3cae1b79126e02b2c7e32..fe0488b086032237687822bb7ddc3fddb89d7339 100644 (file)
@@ -44,7 +44,6 @@ SETTINGS = set(
      'routes',
      'validate_hmac',
      'autoconfigure',
-     'literal_column_headings',
      ])
 
 
@@ -106,9 +105,6 @@ def validate_setting_values(errors, settings):
     # validate_hmac
     boolean_setting(errors, 'pgwui.validate_hmac', settings)
 
-    # literal_column_headings
-    validate_literal_column_headings(errors, settings)
-
 
 def do_validate_hmac(settings):
     '''True unless the user has specificly rejected hmac validation
@@ -131,16 +127,6 @@ def validate_hmac(errors, settings):
         return
 
 
-def validate_literal_column_headings(errors, settings):
-    '''Make sure the values are those allowed
-    '''
-    value = settings.get('pgwui.literal_column_headings')
-    if value is None:
-        return
-    if value not in ('on', 'off', 'ask'):
-        errors.append(server_ex.BadLiteralColumnHeadingsError(value))
-
-
 def parse_assignments(lines):
     '''Return a list of key/value tuples from the lines of a setting
     '''
index ef82da5b02e711f1e8e26b12c938137a7d627fd8..518ac0fe622117feefa13f474759e5dc5efd853b 100644 (file)
@@ -41,13 +41,6 @@ class BadSettingsAbort(ServerError):
         super().__init__('Aborting due to bad setting(s)')
 
 
-class BadLiteralColumnHeadingsError(ServerError):
-    def __init__(self, value):
-        super().__init__(
-            'The "pgwui.literal_column_headings" PGWUI setting must be'
-            '"on", "off", "ask", or not present')
-
-
 class BadHMACError(ServerError):
     pass
 
index f4cc6c139ae619bc8ceec25aca722536d8c6a65e..da17a2f6fd403a3ce40c154ef6f4d860a0b71494 100644 (file)
@@ -300,58 +300,6 @@ mock_validate_hmac = testing.make_mock_fixture(
     pgwui_server_init, 'validate_hmac')
 
 
-# validate_literal_column_headings()
-
-def test_validate_literal_column_headings_nosetting():
-    '''No error is delivered when there's no setting'''
-    errors = []
-    pgwui_server_init.validate_literal_column_headings(errors, {})
-
-    assert errors == []
-
-
-def test_validate_literal_column_headings_on():
-    '''No error is delivered when the setting is "on"'''
-    errors = []
-    pgwui_server_init.validate_literal_column_headings(
-        errors, {'pgwui.literal_column_headings': 'on'})
-
-    assert errors == []
-
-
-def test_validate_literal_column_headings_off():
-    '''No error is delivered when the setting is "off"'''
-    errors = []
-    pgwui_server_init.validate_literal_column_headings(
-        errors, {'pgwui.literal_column_headings': 'off'})
-
-    assert errors == []
-
-
-def test_validate_literal_column_headings_ask():
-    '''No error is delivered when the setting is "ask"'''
-    errors = []
-    pgwui_server_init.validate_literal_column_headings(
-        errors, {'pgwui.literal_column_headings': 'ask'})
-
-    assert errors == []
-
-
-def test_validate_literal_column_headings_bad():
-    '''delivers an error when given a bad value'''
-    errors = []
-    pgwui_server_init.validate_literal_column_headings(
-        errors, {'pgwui.literal_column_headings': 'bad'})
-
-    assert errors
-    assert isinstance(
-        errors[0], server_ex.BadLiteralColumnHeadingsError)
-
-
-mock_validate_literal_column_headings = testing.make_mock_fixture(
-    pgwui_server_init, 'validate_literal_column_headings')
-
-
 # parse_assignments()
 
 def test_parse_assignments_str():