mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Added plugin_config() method
This commit is contained in:
parent
1905c03364
commit
0a14a4846b
6 changed files with 114 additions and 6 deletions
|
|
@ -170,7 +170,7 @@ class Datasette:
|
|||
def metadata(self, key=None, database=None, table=None, fallback=True):
|
||||
"""
|
||||
Looks up metadata, cascading backwards from specified level.
|
||||
Returns None if metadata value is not foundself.
|
||||
Returns None if metadata value is not found.
|
||||
"""
|
||||
assert not (database is None and table is not None), \
|
||||
"Cannot call metadata() with table= specified but not database="
|
||||
|
|
@ -199,6 +199,17 @@ class Datasette:
|
|||
m.update(item)
|
||||
return m
|
||||
|
||||
def plugin_config(
|
||||
self, plugin_name, database=None, table=None, fallback=True
|
||||
):
|
||||
"Return config for plugin, falling back from specified database/table"
|
||||
plugins = self.metadata(
|
||||
"plugins", database=database, table=table, fallback=fallback
|
||||
)
|
||||
if plugins is None:
|
||||
return None
|
||||
return plugins.get(plugin_name)
|
||||
|
||||
def app_css_hash(self):
|
||||
if not hasattr(self, "_app_css_hash"):
|
||||
self._app_css_hash = hashlib.sha1(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from pluggy import HookimplMarker
|
||||
from pluggy import HookspecMarker
|
||||
|
||||
hookspec = HookspecMarker('datasette')
|
||||
hookimpl = HookimplMarker('datasette')
|
||||
hookspec = HookspecMarker("datasette")
|
||||
hookimpl = HookimplMarker("datasette")
|
||||
|
||||
|
||||
@hookspec
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue