You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2020/11/11 04:23:20 UTC
[incubator-superset] 01/01: improve feature flags
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch chevron
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit ed7894757269ed8ed3c9e7e27020560ac3c926b2
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Nov 9 21:19:01 2020 -0800
improve feature flags
---
superset/config.py | 8 ++++++++
superset/jinja_context.py | 14 ++++++++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/superset/config.py b/superset/config.py
index 2e2b2e8..862d97b 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -301,8 +301,16 @@ DEFAULT_FEATURE_FLAGS: Dict[str, bool] = {
# Experimental feature introducing a client (browser) cache
"CLIENT_CACHE": False,
"ENABLE_EXPLORE_JSON_CSRF_PROTECTION": False,
+ # -----------------------------------
+ # Template processing section
+ # -----------------------------------
+ # Whether any template processing is enabled at all
"ENABLE_TEMPLATE_PROCESSING": False,
+ # Use jinja2, most powerful but has potential security pitfalls
+ "JINJA_TEMPLATE_PROCESSING": True,
+ # Use Chevron, a python implementation of mustache.js
"CHEVRON_TEMPLATE_PROCESSING": False,
+ # -----------------------------------
"KV_STORE": False,
"PRESTO_EXPAND_DATA": False,
# Exposes API endpoint to compute thumbnails
diff --git a/superset/jinja_context.py b/superset/jinja_context.py
index 537add2..e511a9e 100644
--- a/superset/jinja_context.py
+++ b/superset/jinja_context.py
@@ -343,12 +343,14 @@ def get_template_processor(
query: Optional["Query"] = None,
**kwargs: Any,
) -> BaseTemplateProcessor:
+ template_processor = None
if feature_flag_manager.is_feature_enabled("ENABLE_TEMPLATE_PROCESSING"):
- template_processor = template_processors.get(
- database.backend, BaseTemplateProcessor
- )
- elif feature_flag_manager.is_feature_enabled("CHEVRON_TEMPLATE_PROCESSING"):
- template_processor = ChevronTemplateProcessor
- else:
+ if feature_flag_manager.is_feature_enabled("JINJA_TEMPLATE_PROCESSING"):
+ template_processor = template_processors.get(
+ database.backend, BaseTemplateProcessor
+ )
+ elif feature_flag_manager.is_feature_enabled("CHEVRON_TEMPLATE_PROCESSING"):
+ template_processor = ChevronTemplateProcessor
+ if not template_processor:
template_processor = NoOpTemplateProcessor
return template_processor(database=database, table=table, query=query, **kwargs)