jaaql-middleware-python 5.3.15__tar.gz → 5.3.19__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/PKG-INFO +1 -1
  2. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/constants.py +1 -1
  3. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/db/db_interface.py +9 -0
  4. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/db/db_pg_interface.py +6 -1
  5. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/exceptions/jaaql_interpretable_handled_errors.py +16 -0
  6. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/interpreter/interpret_jaaql.py +5 -4
  7. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/model.py +17 -1
  8. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql_middleware_python.egg-info/PKG-INFO +1 -1
  9. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/LICENSE.txt +0 -0
  10. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/README.md +0 -0
  11. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/__init__.py +0 -0
  12. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/config/__init__.py +0 -0
  13. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/config/config-docker.ini +0 -0
  14. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/config/config-test.ini +0 -0
  15. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/config/config.ini +0 -0
  16. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/config_constants.py +0 -0
  17. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/db/__init__.py +0 -0
  18. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/db/db_utils.py +0 -0
  19. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/db/db_utils_no_circ.py +0 -0
  20. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/documentation/__init__.py +0 -0
  21. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/documentation/documentation_internal.py +0 -0
  22. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/documentation/documentation_public.py +0 -0
  23. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/documentation/documentation_shared.py +0 -0
  24. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/email/__init__.py +0 -0
  25. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/email/email_manager.py +0 -0
  26. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/email/email_manager_service.py +0 -0
  27. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/email/patch_ems.py +0 -0
  28. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/exceptions/__init__.py +0 -0
  29. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/exceptions/custom_http_status.py +0 -0
  30. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/exceptions/http_status_exception.py +0 -0
  31. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/exceptions/not_yet_implement_exception.py +0 -0
  32. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/generated_constants.py +0 -0
  33. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/interpreter/__init__.py +0 -0
  34. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/jaaql.py +0 -0
  35. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/migrations/__init__.py +0 -0
  36. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/migrations/migrations.py +0 -0
  37. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/__init__.py +0 -0
  38. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/base_controller.py +0 -0
  39. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/base_model.py +0 -0
  40. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/controller.py +0 -0
  41. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/controller_interface.py +0 -0
  42. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/exception_queries.py +0 -0
  43. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/generated_queries.py +0 -0
  44. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/handmade_queries.py +0 -0
  45. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/model_interface.py +0 -0
  46. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/mvc/response.py +0 -0
  47. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/openapi/__init__.py +0 -0
  48. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/openapi/swagger_documentation.py +0 -0
  49. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/patch.py +0 -0
  50. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/01.install_domains.generated.sql +0 -0
  51. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/02.install_super_user.exceptions.sql +0 -0
  52. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/03.install_super_user.handwritten.sql +0 -0
  53. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/04.install_jaaql_data_structures.generated.sql +0 -0
  54. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/05.install_static_data.generated.sql +0 -0
  55. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/06.install_jaaql.exceptions.sql +0 -0
  56. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/ZZZZ.generated_functions_views_and_permissions.sql +0 -0
  57. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/ZZZZ.reset_references.sql +0 -0
  58. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/scripts/swagger_template.html +0 -0
  59. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/services/__init__.py +0 -0
  60. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/services/cached_canned_query_service.py +0 -0
  61. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/services/migrations_manager_service.py +0 -0
  62. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/services/patch_mms.py +0 -0
  63. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/services/patch_shared_var_service.py +0 -0
  64. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/services/shared_var_service.py +0 -0
  65. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/__init__.py +0 -0
  66. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/bootstrap_secrets.py +0 -0
  67. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/cron.py +0 -0
  68. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/crypt_utils.py +0 -0
  69. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/options.py +0 -0
  70. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/utils.py +0 -0
  71. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/utils_no_project_imports.py +0 -0
  72. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql/utilities/vault.py +0 -0
  73. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql_middleware_python.egg-info/SOURCES.txt +0 -0
  74. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql_middleware_python.egg-info/dependency_links.txt +0 -0
  75. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql_middleware_python.egg-info/requires.txt +0 -0
  76. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/jaaql_middleware_python.egg-info/top_level.txt +0 -0
  77. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/setup.cfg +0 -0
  78. {jaaql_middleware_python-5.3.15 → jaaql_middleware_python-5.3.19}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaaql-middleware-python
3
- Version: 5.3.15
3
+ Version: 5.3.19
4
4
  Summary: The jaaql package, allowing for rapid development and deployment of RESTful HTTP applications
5
5
  Home-page: https://github.com/JAAQL/JAAQL-middleware-python
6
6
  Author: Software Quality Measurement and Improvement bv
@@ -218,5 +218,5 @@ ROLE__dba = "dba"
218
218
 
219
219
  PROTOCOL__postgres = "postgresql://"
220
220
 
221
- VERSION = "5.3.15"
221
+ VERSION = "5.3.19"
222
222
 
@@ -120,9 +120,18 @@ class DBInterface(ABC):
120
120
  # re-run on a fresh connection; any other commit failure is a genuine error.
121
121
  if self.is_connection_error(commit_err):
122
122
  raise ConnectionLostError(str(commit_err))
123
+ translated = self.translate_commit_error(commit_err)
124
+ if translated is not None:
125
+ raise translated
123
126
  raise HttpStatusException("Commit failed, transaction not persisted: " + str(commit_err),
124
127
  HTTPStatus.INTERNAL_SERVER_ERROR)
125
128
 
129
+ def translate_commit_error(self, commit_err):
130
+ # A deferred constraint trigger raises at COMMIT rather than during its statement. When what it
131
+ # raises is an error the statement path would have handed back as a handled error, a subclass
132
+ # returns that error here so the caller sees the same response either way; None keeps the 500
133
+ return None
134
+
126
135
  def handle_error(self, conn, err, echo=ECHO__none):
127
136
  commit_err = self.__attempt_commit_rollback(conn, err)
128
137
  if err is None and commit_err is not None:
@@ -12,7 +12,7 @@ from jaaql.constants import ERR__invalid_token
12
12
  from jaaql.db.db_interface import DBInterface, ECHO__none, CHAR__newline
13
13
  from jaaql.exceptions.http_status_exception import *
14
14
  from jaaql.exceptions.custom_http_status import CustomHTTPStatus
15
- from jaaql.exceptions.jaaql_interpretable_handled_errors import UserUnauthorized
15
+ from jaaql.exceptions.jaaql_interpretable_handled_errors import UserUnauthorized, handled_procedure_error_from_raise
16
16
  from jaaql.constants import KEY__database
17
17
 
18
18
  ERR__connect_db = "Could not create connection to database!"
@@ -443,6 +443,11 @@ class DBPGInterface(DBInterface):
443
443
  # persisted nothing, so the operation is safe to retry on a fresh connection.
444
444
  return isinstance(ex, OperationalError)
445
445
 
446
+ def translate_commit_error(self, commit_err):
447
+ if not isinstance(commit_err, psycopg.Error):
448
+ return None
449
+ return handled_procedure_error_from_raise(commit_err)
450
+
446
451
  def handle_db_error(self, err, echo):
447
452
  if isinstance(err, ProgrammingError) and hasattr(err, 'pgresult'):
448
453
  err = err.pgresult.error_message.decode("UTF-8")
@@ -1,3 +1,6 @@
1
+ import json
2
+
3
+ from jaaql.constants import SQLStateJaaql
1
4
  from jaaql.exceptions.http_status_exception import JaaqlInterpretableHandledError
2
5
 
3
6
 
@@ -43,6 +46,19 @@ class HandledProcedureError(JaaqlInterpretableHandledError):
43
46
  )
44
47
 
45
48
 
49
+ def handled_procedure_error_from_raise(ex):
50
+ # A JQ000 raise carries a JSON array of error records, whether it surfaced during its statement or at
51
+ # COMMIT from a deferred trigger; one that does not is left to the caller as an unhandled error
52
+ diag = getattr(ex, "diag", None)
53
+ if diag is None or diag.sqlstate != SQLStateJaaql:
54
+ return None
55
+ try:
56
+ descriptor = json.loads(diag.message_primary)
57
+ except (TypeError, ValueError):
58
+ return None
59
+ return HandledProcedureError(message=None, index=None, table_name=None, descriptor=descriptor)
60
+
61
+
46
62
  class UnhandledQueryError(JaaqlInterpretableHandledError):
47
63
  def __init__(self, message, _set, table_name=None, column_name=None, descriptor=None):
48
64
  super().__init__(
@@ -14,8 +14,8 @@ import json
14
14
  from jaaql.db.db_interface import DBInterface, ECHO__none
15
15
  from psycopg.errors import OperationalError, Error
16
16
  from jaaql.constants import KEY__position, KEY__file, KEY__application, KEY__error, KEY__error_row_number, KEY__error_query, \
17
- KEY__error_set, KEY__error_index, SQLStateJaaql, KEY__restrictions, REGEX__dmbs_object_name
18
- from jaaql.exceptions.jaaql_interpretable_handled_errors import DatabaseOperationalError, HandledProcedureError, UnhandledQueryError, UnhandledProcedureError, \
17
+ KEY__error_set, KEY__error_index, KEY__restrictions, REGEX__dmbs_object_name
18
+ from jaaql.exceptions.jaaql_interpretable_handled_errors import handled_procedure_error_from_raise, DatabaseOperationalError, HandledProcedureError, UnhandledQueryError, UnhandledProcedureError, \
19
19
  SingletonExpected
20
20
  from typing import Union
21
21
  from functools import lru_cache
@@ -605,8 +605,9 @@ ORDER BY d.column_name;
605
605
  }
606
606
  )
607
607
  elif isinstance(ex, Error):
608
- if ex.diag.sqlstate == SQLStateJaaql:
609
- err = HandledProcedureError(message=None, index=None, table_name=None, descriptor=json.loads(ex.diag.message_primary))
608
+ handled = handled_procedure_error_from_raise(ex)
609
+ if handled is not None:
610
+ err = handled
610
611
  elif query_key == "_jaaql_procedure":
611
612
  err = UnhandledProcedureError(
612
613
  message=str(ex),
@@ -27,6 +27,7 @@ from jaaql.exceptions.jaaql_interpretable_handled_errors import *
27
27
  from jaaql.db.db_pg_interface import DBPGInterface, QUERY__dba_query_external
28
28
  from jaaql.email.email_manager_service import EmailAttachment
29
29
  from jaaql.mvc.base_model import BaseJAAQLModel, VAULT_KEY__jwt_crypt_key
30
+ from jaaql.utilities.bootstrap_secrets import get_or_seed_vault_secret
30
31
  from jaaql.exceptions.http_status_exception import HttpStatusException, ERR__already_installed, HttpSingletonStatusException
31
32
  from os.path import join
32
33
  from jaaql.interpreter.interpret_jaaql import KEY_query, KEY_parameters
@@ -1489,7 +1490,7 @@ WHERE
1489
1490
  master_pid = os.getppid()
1490
1491
 
1491
1492
  def _deterministic_restart():
1492
- time.sleep(1) # let /internal/clean's 200 reach the caller before we bounce the server
1493
+ time.sleep(0.2) # let /internal/clean's 200 reach the caller before we bounce the server
1493
1494
  os.kill(master_pid, signal.SIGQUIT)
1494
1495
 
1495
1496
  threading.Thread(target=_deterministic_restart, daemon=True).start()
@@ -1519,6 +1520,21 @@ WHERE
1519
1520
  sql = self._lookup_cached_query(QUERY_CACHE_REF__health)
1520
1521
  execute_supplied_statement_singleton(self.jaaql_lookup_connection, sql, as_objects=True)
1521
1522
 
1523
+ def install_on_bootup(self):
1524
+ # Called from the gunicorn master (docker/gunicorn_config.py, when_ready) while preload_app has
1525
+ # built this model and no worker has forked yet, so every worker starts already installed. The
1526
+ # migrations manager still installs over HTTP if this does not run, but that path installs inside
1527
+ # one worker and then has to bounce the whole master (child_exit) before the others can see it.
1528
+ if not self.is_container or self.has_installed:
1529
+ return
1530
+ super_db_password = get_or_seed_vault_secret(self.vault, VAULT_KEY__super_db_password, "SUPER_PASSWORD", generate_if_missing=True)
1531
+ jaaql_password = get_or_seed_vault_secret(self.vault, VAULT_KEY__jaaql_password, "JAAQL_PASSWORD", generate_if_missing=True)
1532
+ self.install(None, jaaql_password, super_db_password, self.install_key, True, do_reboot=False)
1533
+ # Nothing may carry a pooled connection across the fork; each worker opens its own in post_worker_init
1534
+ if self.jaaql_lookup_connection is not None:
1535
+ self.jaaql_lookup_connection.close()
1536
+ DBPGInterface.close_all_pools()
1537
+
1522
1538
  def install(self, db_connection_string: str, jaaql_password: str, super_db_password: str, install_key: str, allow_uninstall: bool,
1523
1539
  do_reboot: bool = True, jaaql_db_password: str = None):
1524
1540
  if self.jaaql_lookup_connection is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaaql-middleware-python
3
- Version: 5.3.15
3
+ Version: 5.3.19
4
4
  Summary: The jaaql package, allowing for rapid development and deployment of RESTful HTTP applications
5
5
  Home-page: https://github.com/JAAQL/JAAQL-middleware-python
6
6
  Author: Software Quality Measurement and Improvement bv