Skip to content

Commit

Permalink
datasette argument
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Nov 17, 2023
1 parent 43cd59d commit 3c2808e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion datasette_enrichments_jinja.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from datasette_enrichments import Enrichment
from datasette import hookimpl

Expand Down Expand Up @@ -42,7 +43,7 @@ class ConfigForm(Form):

return ConfigForm

async def initialize(self, db, table, config):
async def initialize(self, datasette, db, table, config):
# Ensure column exists
output_column = config["output_column"][0]

Expand All @@ -55,6 +56,7 @@ def add_column_if_not_exists(conn):

async def enrich_batch(
self,
datasette: Datasette,
db: Database,
table: str,
rows: List[dict],
Expand Down
3 changes: 2 additions & 1 deletion tests/test_enrichments_jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ async def test_enrichment(tmpdir):
db["items"].insert_all(rows)
ds_db = datasette.get_database("data")
enrichment = JinjaSandbox()
await enrichment.initialize(ds_db, "items", config)
await enrichment.initialize(datasette, ds_db, "items", config)
# It should now have a template_output column
assert "template_output" in db["items"].columns_dict
# Now enrich the batch
await enrichment.enrich_batch(
datasette=datasette,
db=ds_db,
table="items",
rows=rows,
Expand Down

0 comments on commit 3c2808e

Please sign in to comment.