mistercrunch commented on a change in pull request #6220: [SIP-5] Open a new 
/api/v1/query endpoint that takes query_obj
URL: 
https://github.com/apache/incubator-superset/pull/6220#discussion_r230997617
 
 

 ##########
 File path: superset/common/query_context.py
 ##########
 @@ -0,0 +1,31 @@
+from typing import Dict
+
+from superset import db
+from superset.connectors.connector_registry import ConnectorRegistry
+from .query_object import QueryObject
+
+
+class QueryContext():
+    """
+    The query context contains the query object and additional fields necessary
+    to retrieve the data payload for a given viz.
+    """
+    # TODO: Type datasource and query_object dictionary with TypedDict when it 
becomes
+    # a vanilla python type https://github.com/python/mypy/issues/5288
+    def __init__(
+            self,
+            datasource: Dict,
+            query_object: Dict,
+    ):
+        self._datasource = 
ConnectorRegistry.get_datasource(datasource.get('type'),
+                                                            
datasource.get('id'),
+                                                            db.session)
+        self._query_object = QueryObject(**query_object)
+
+    @property
+    def datasource(self):
 
 Review comment:
   NIT: [from what I've seen] the convention in Python is to not use getters 
unless you need them, you can simply `self.query_object = 
QueryObject(**query_object)`, later on if you need to make something private 
and force some on-the-fly logic, you add the getter property

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to