New ds.metadata() method

This commit is contained in:
Simon Willison 2018-08-13 07:56:50 -07:00
commit 1905c03364
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
5 changed files with 57 additions and 23 deletions

View file

@ -74,7 +74,7 @@ class BaseView(RenderMixin):
def table_metadata(self, database, table):
"Fetch table-specific metadata."
return self.ds.metadata.get("databases", {}).get(database, {}).get(
return (self.ds.metadata("databases") or {}).get(database, {}).get(
"tables", {}
).get(
table, {}
@ -314,7 +314,7 @@ class BaseView(RenderMixin):
end = time.time()
data["query_ms"] = (end - start) * 1000
for key in ("source", "source_url", "license", "license_url"):
value = self.ds.metadata.get(key)
value = self.ds.metadata(key)
if value:
data[key] = value
if _format in ("json", "jsono"):