villebro commented on a change in pull request #9054: [database] new, select 
star API migration
URL: 
https://github.com/apache/incubator-superset/pull/9054#discussion_r377009499
 
 

 ##########
 File path: superset/views/database/decorators.py
 ##########
 @@ -0,0 +1,58 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import functools
+
+from flask import g
+from flask_babel import lazy_gettext as _
+
+from superset.models.core import Database
+from superset.utils.core import parse_js_uri_path_item
+
+
+def check_datasource_access(f):
+    """
+    A Decorator that checks if a user has datasource access
+    """
+
+    def wraps(
+        self, pk: int, table_name: str, schema_name: str = None
+    ):  # pylint: disable=invalid-name
+        schema_name_parsed = parse_js_uri_path_item(schema_name, 
eval_undefined=True)
+        table_name_parsed = parse_js_uri_path_item(table_name)
+        if not table_name_parsed:
+            return self.response_422(message=_("Table name could not be 
parsed"))
 
 Review comment:
   In practice `table_name_parsed` will only be falsy if the original 
`table_name` is `None`. So a more appropriate error message would perhaps be 
"Table name undefined" or similar.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to