You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2021/07/13 20:30:33 UTC

[superset] 01/01: fix: no lazy translation on SupersetError

This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch fix_lazy
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 014e9bdbc26cae7415453a5bda20473716f4a1f4
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Tue Jul 13 13:29:37 2021 -0700

    fix: no lazy translation on SupersetError
---
 superset/views/core.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/superset/views/core.py b/superset/views/core.py
index b04b93c..a87cb2c 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2037,15 +2037,17 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
             database_id = data["dbId"]
         except KeyError:
             raise SupersetGenericErrorException(
-                "One or more required fields are missing in the request. Please try "
-                "again, and if the problem persists conctact your administrator.",
+                __(
+                    "One or more required fields are missing in the request. Please try "
+                    "again, and if the problem persists conctact your administrator."
+                ),
                 status=400,
             )
         database = db.session.query(Database).get(database_id)
         if not database:
             raise SupersetErrorException(
                 SupersetError(
-                    message="The database was not found.",
+                    message=__("The database was not found."),
                     error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
                     level=ErrorLevel.ERROR,
                 ),
@@ -2115,7 +2117,7 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
             )
             raise SupersetErrorException(
                 SupersetError(
-                    message="The database was not found.",
+                    message=__("The database was not found."),
                     error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
                     level=ErrorLevel.ERROR,
                 ),
@@ -2456,7 +2458,7 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
         except Exception as ex:  # pylint: disable=broad-except
             logger.exception("Query %i: %s", query.id, str(ex))
 
-            message = _("Failed to start remote query on a worker.")
+            message = __("Failed to start remote query on a worker.")
             error = SupersetError(
                 message=message,
                 error_type=SupersetErrorType.ASYNC_WORKERS_ERROR,
@@ -2620,7 +2622,7 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
         mydb = session.query(Database).get(database_id)
         if not mydb:
             raise SupersetGenericErrorException(
-                _(
+                __(
                     "The database referenced in this query was not found. Please "
                     "contact an administrator for further assistance or try again."
                 )
@@ -2663,7 +2665,7 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
             query_id = None
         if not query_id:
             raise SupersetGenericErrorException(
-                _(
+                __(
                     "The query record was not created as expected. Please "
                     "contact an administrator for further assistance or try again."
                 )
@@ -2674,7 +2676,7 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
         try:
             query.raise_for_access()
         except SupersetSecurityException as ex:
-            message = _(
+            message = __(
                 "You are not authorized to see this query. If you think this "
                 "is an error, please reach out to your administrator."
             )
@@ -2703,7 +2705,7 @@ class Superset(BaseSupersetView):  # pylint: disable=too-many-public-methods
             query.status = QueryStatus.FAILED
             session.commit()
             raise SupersetTemplateParamsErrorException(
-                message=_(
+                message=__(
                     'The query contains one or more malformed template parameters. Please check your query and confirm that all template parameters are surround by double braces, for example, "{{ ds }}". Then, try running your query again.'
                 ),
                 error=SupersetErrorType.INVALID_TEMPLATE_PARAMS_ERROR,