example setting checker from PGWUI_Upload is::
from pgwui_common import checkset
+ from . import exceptions as upload_ex
PGWUI_COMPONENT = 'pgwui_upload'
UPLOAD_SETTINGS = ['menu_label',
+ 'literal_column_headings',
]
REQUIRED_SETTINGS = []
BOOLEAN_SETTINGS = []
+ def validate_literal_column_headings(errors, settings):
+ '''Make sure the values are those allowed
+ '''
+ value = settings.get('literal_column_headings')
+ if value is None:
+ return
+ if value not in ('on', 'off', 'ask'):
+ errors.append(upload_ex.BadLiteralColumnHeadingsError(value))
+
+
def check_settings(component_config):
'''Check that all pgwui_upload specific settings are good.
This includes:
checking the boolean settings
checking that the values of other settings are valid
'''
- return (
- checkset.unknown_settings(
- PGWUI_COMPONENT, UPLOAD_SETTINGS, component_config)
- .extend(checkset.require_settings(
- PGWUI_COMPONENT, REQUIRED_SETTINGS, component_config)
- .extend(checkset.boolean_settings(
- PGWUI_COMPONENT, BOOLEAN_SETTINGS, component_config))))
+ errors = []
+ errors.extend(checkset.unknown_settings(
+ PGWUI_COMPONENT, UPLOAD_SETTINGS, component_config))
+ errors.extend(checkset.require_settings(
+ PGWUI_COMPONENT, REQUIRED_SETTINGS, component_config))
+ errors.extend(checkset.boolean_settings(
+ PGWUI_COMPONENT, BOOLEAN_SETTINGS, component_config))
+ validate_literal_column_headings(errors, component_config)
+
+ return errors
+
When establishing the entrypoint for your PGWUI componenent the name
of the entrypoint is the name of the pgwui component. The value