{"html_url": "https://github.com/simonw/datasette/issues/446#issuecomment-702459432", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/446", "id": 702459432, "node_id": "MDEyOklzc3VlQ29tbWVudDcwMjQ1OTQzMg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-02T00:08:47Z", "updated_at": "2020-10-02T00:08:47Z", "author_association": "OWNER", "body": "I've decided not to bother with this, especially having redesigned some hooks to return Datasette standard `Response` objects.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 440134714, "label": "Define mechanism for plugins to return structured data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/446#issuecomment-498838841", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/446", "id": 498838841, "node_id": "MDEyOklzc3VlQ29tbWVudDQ5ODgzODg0MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-04T20:51:37Z", "updated_at": "2019-06-04T20:51:37Z", "author_association": "OWNER", "body": "So the Python 3.7 way to do this would be dataclasses, but I still want to support 3.5.\r\n\r\nThis excellent essay has made me think attrs might be the way to go: https://www.revsys.com/tidbits/dataclasses-and-attrs-when-and-why/", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 440134714, "label": "Define mechanism for plugins to return structured data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/446#issuecomment-489222223", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/446", "id": 489222223, "node_id": "MDEyOklzc3VlQ29tbWVudDQ4OTIyMjIyMw==", "user": {"value": 45057, "label": "russss"}, "created_at": "2019-05-03T20:01:19Z", "updated_at": "2019-05-03T20:01:29Z", "author_association": "CONTRIBUTOR", "body": "Also I have a slight preference against (ab)using `__slots__` to enforce fields, although I have done it myself in the past. It would be possible to do this with `__setattr__` instead, although that's an implementation detail and I'm not too fussed about it.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 440134714, "label": "Define mechanism for plugins to return structured data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/446#issuecomment-489221481", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/446", "id": 489221481, "node_id": "MDEyOklzc3VlQ29tbWVudDQ4OTIyMTQ4MQ==", "user": {"value": 45057, "label": "russss"}, "created_at": "2019-05-03T19:58:31Z", "updated_at": "2019-05-03T19:58:31Z", "author_association": "CONTRIBUTOR", "body": "In this particular case I don't think there's an issue making all those required. However, I suspect we might have to allow optional values at some point - my preferred solution to russss/datasette-geo#2 would need one.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 440134714, "label": "Define mechanism for plugins to return structured data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/446#issuecomment-489209255", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/446", "id": 489209255, "node_id": "MDEyOklzc3VlQ29tbWVudDQ4OTIwOTI1NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-05-03T19:15:23Z", "updated_at": "2019-05-03T19:16:34Z", "author_association": "OWNER", "body": "The `register_output_renderer()` hook currently returns a dictionary with `body`, `content_type` and `status_code` keys but each of these keys are optionaly. I'm tempted to make all three required to better fit this model - @russss any objections?\r\n\r\nAlternative would be to support default values for properties of the `DataSpec` subclass - maybe:\r\n\r\n`__defaults__ = {\"body\": \"\", \"content_type\": \"text/plain\", \"status_code\": 200}`", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 440134714, "label": "Define mechanism for plugins to return structured data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/446#issuecomment-489204605", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/446", "id": 489204605, "node_id": "MDEyOklzc3VlQ29tbWVudDQ4OTIwNDYwNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-05-03T18:59:51Z", "updated_at": "2019-05-03T18:59:59Z", "author_association": "OWNER", "body": "Potential design:\r\n\r\n```python\r\nfrom collections import OrderedDict\r\n\r\n\r\nclass DataSpec:\r\n __slots__ = []\r\n\r\n def __init__(self, **kwargs):\r\n if list(kwargs.keys()) != self.__slots__:\r\n raise TypeError(\r\n \"{}() has required arguments {} (got {})\".format(\r\n self.__class__.__name__, self.__slots__, list(kwargs.keys())\r\n )\r\n )\r\n for key in self.__slots__:\r\n setattr(self, key, kwargs[key])\r\n\r\n def __repr__(self):\r\n return \"<{} {}>\".format(self.__class__.__name__, dict(self.as_dict()))\r\n\r\n def as_dict(self):\r\n return OrderedDict([(key, getattr(self, key)) for key in self.__slots__])\r\n\r\n\r\nclass Output(DataSpec):\r\n __slots__ = [\"body\", \"content_type\", \"status_code\"]\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 440134714, "label": "Define mechanism for plugins to return structured data"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/446#issuecomment-489167692", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/446", "id": 489167692, "node_id": "MDEyOklzc3VlQ29tbWVudDQ4OTE2NzY5Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-05-03T17:02:24Z", "updated_at": "2019-05-03T17:02:24Z", "author_association": "OWNER", "body": "I looked at using namedtuples for this but hey have one major constraint: there isn't a clean way to convert them to dictionary-style JSON: https://bugs.python.org/issue30343\r\n\r\nSo something that uses a class which knows how to be rendered as JSON would be a better fit.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 440134714, "label": "Define mechanism for plugins to return structured data"}, "performed_via_github_app": null}