Closed simonw closed 4 years ago
After further investigation I got here:
(Pdb) list
717 request=request,
718 datasette=self,
719 ):
720 extra_script = await await_me_maybe(extra_script)
721 body_scripts.append(Markup(extra_script))
722
723 extra_template_vars = {}
724 # pylint: disable=no-member
725 for extra_vars in pm.hook.extra_template_vars(
726 template=template.name,
727 database=context.get("database"),
(Pdb) locals()
{'templates': ['edit_schema_table.html'], 'context': {'database': <Database: fixtures (mutable, size=258048)>, 'table': 'attraction_characteristic', 'columns': [{'name': 'pk', 'type': 'INTEGER'}, {'name': 'name', 'type': 'TEXT'}], 'schema': 'CREATE TABLE attraction_characteristic (\n pk integer primary key,\n name text\n)', 'types': ['TEXT', 'REAL', 'INTEGER', 'BLOB']}, 'view_name': None, 'template': <Template 'edit_schema_table.html'>, 'body_scripts': [], 'request': <datasette.utils.asgi.Request object at 0x10d370a90>, 'self': <datasette.app.Datasette object at 0x10b31f190>}
The problem is this code: https://github.com/simonw/datasette-cluster-map/blob/b8004700910c11c4416a5e94b47acc57cf2417b1/datasette_cluster_map/__init__.py#L50-L90
It's running a check based on the columns
, but it turns out those are simply pulled out of the context - so they won't make sense if the plugin hook is running for a page other than a default query or template page.
view_name': None,
is the clue we can hook into here.
This plugin broke my installation of
datasette-edit-schema
. I got this error:'dict' object has no attribute 'lower'
The traceback lead me here: