More general description of the module.
'''
+
# There are main objects, and their subclasses, here:
# LoadedForm
# DBHandler (generally referred to a an "upload handler", at present)
return super().write_response(response)
-# Utility functions
-
-def textualize(st):
- '''
- Return pg representation of NULL for None when string st is None.
- '''
- return 'NULL' if st is None else st
-
-
-def is_checked(val):
- '''Is the value something a html input entity recognizes as checked?'''
- return val == CHECKED
-
-
-# Some functions for logging
-
-def escape_eol(string):
- '''Change all the newlines to \n.'''
- return string.replace('\n', r'\n')
-
-
-def format_exception(ex):
- '''Return an exception formatted as suffix text for a log message.'''
- if isinstance(ex, psycopg.errors.DatabaseError):
- diag = ex.diag
- msg = diag.message_primary
- if hasattr(diag, 'message_detail'):
- msg += ', detail={0}'.format(escape_eol(diag.message_detail))
- if hasattr(diag, 'message_hint'):
- msg += ', hint={0}'.format(escape_eol(diag.message_hint))
- elif isinstance(ex, core_ex.UploadError):
- msg = ex.e
- if ex.descr != '':
- msg += ' {0}'.format(escape_eol(ex.descr))
- if ex.detail != '':
- msg += ' {0}'.format(escape_eol(ex.detail))
- else:
- msg = ''
- if msg != '':
- msg = ': Error is ({0})'.format(msg)
- return msg
-
-
# Upload processing
@attrs.define(slots=False)
--- /dev/null
+# Copyright (C) 2013, 2014, 2015, 2018, 2020, 2021, 2024 The Meme Factory, Inc.
+# http://www.karlpinc.com/
+
+# This file is part of PGWUI_Core.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+# Karl O. Pinc <kop@karlpinc.com>
+
+'''Utility functions
+'''
+from . import exceptions as core_ex
+import pgwui_core.constants
+import psycopg.errors
+
+
+# Utility functions
+
+def textualize(st):
+ '''
+ Return pg representation of NULL for None when string st is None.
+ '''
+ return 'NULL' if st is None else st
+
+
+def is_checked(val):
+ '''Is the value something a html input entity recognizes as checked?'''
+ return val == pgwui_core.constants.CHECKED
+
+
+# Some functions for logging
+
+def escape_eol(string):
+ '''Change all the newlines to \n.'''
+ return string.replace('\n', r'\n')
+
+
+def format_exception(ex):
+ '''Return an exception formatted as suffix text for a log message.'''
+ if isinstance(ex, psycopg.errors.DatabaseError):
+ diag = ex.diag
+ msg = diag.message_primary
+ if hasattr(diag, 'message_detail'):
+ msg += ', detail={0}'.format(escape_eol(diag.message_detail))
+ if hasattr(diag, 'message_hint'):
+ msg += ', hint={0}'.format(escape_eol(diag.message_hint))
+ elif isinstance(ex, core_ex.UploadError):
+ msg = ex.e
+ if ex.descr != '':
+ msg += ' {0}'.format(escape_eol(ex.descr))
+ if ex.detail != '':
+ msg += ' {0}'.format(escape_eol(ex.detail))
+ else:
+ msg = ''
+ if msg != '':
+ msg = ': Error is ({0})'.format(msg)
+ return msg