Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename datasette.config() method to datasette.setting() #1107

Closed
simonw opened this issue Nov 24, 2020 · 5 comments
Closed

Rename datasette.config() method to datasette.setting() #1107

simonw opened this issue Nov 24, 2020 · 5 comments

Comments

@simonw
Copy link
Owner

simonw commented Nov 24, 2020

Part of #1105. Thankfully this isn't yet part of the documented public API on https://docs.datasette.io/en/stable/internals.html

@simonw
Copy link
Owner Author

simonw commented Nov 24, 2020

Are there any plugins that use this API even though it isn't documented?

@simonw
Copy link
Owner Author

simonw commented Nov 24, 2020

I ran rg '.config\(' datasette-*/ in my top-level directory:

datasette-sentry/test_datasette_sentry.py:    def plugin_config(self, name):
datasette-sentry/datasette_sentry.py:    config = datasette.plugin_config("datasette-sentry") or {}
datasette-render-markdown/datasette_render_markdown/__init__.py:        datasette.plugin_config(
datasette-render-images/datasette_render_images.py:        plugin_config = datasette.plugin_config("datasette-render-images") or {}
datasette-render-html/datasette_render_html.py:    config = datasette.plugin_config(
datasette-render-timestamps/datasette_render_timestamps/__init__.py:        datasette.plugin_config(
datasette-permissions-sql/datasette_permissions_sql/__init__.py:        for rule in datasette.plugin_config("datasette-permissions-sql") or []:
datasette-mask-columns/datasette_mask_columns/__init__.py:            datasette.plugin_config("datasette-mask-columns", database=database) or {}
datasette-mask-columns/datasette_mask_columns/__init__.py:    masks = datasette.plugin_config("datasette-mask-columns", database=database) or {}
datasette-media/datasette_media/__init__.py:    plugin_config = datasette.plugin_config("datasette-media") or {}
datasette-insert/datasette_insert/__init__.py:    plugin_config = datasette.plugin_config("datasette-insert") or {}
datasette-indieauth/datasette_indieauth/__init__.py:    plugin_config = datasette.plugin_config("datasette-indieauth") or {}
datasette-graphql/datasette_graphql/__init__.py:    config = datasette.plugin_config("datasette-graphql") or {}
datasette-graphql/datasette_graphql/__init__.py:    config = datasette.plugin_config("datasette-graphql") or {}
datasette-graphql/datasette_graphql/utils.py:            auto_camelcase=(datasette.plugin_config("datasette-graphql") or {}).get(
datasette-graphql/datasette_graphql/utils.py:    table_plugin_config = datasette.plugin_config(
datasette-graphql/datasette_graphql/utils.py:    def config(self, key):
datasette-graphql/datasette_graphql/utils.py:        return self.__wrapped__.config(key)
datasette-init/datasette_init/__init__.py:        config = datasette.plugin_config("datasette-init")
datasette-edit-templates/datasette_edit_templates/__init__.py:    plugin_config = datasette.plugin_config("datasette-edit-templates") or {}
datasette-cors/datasette_cors.py:    config = datasette.plugin_config("datasette-cors") or {}
datasette-cluster-map-old/build/lib/datasette_cluster_map/__init__.py:        datasette.plugin_config("datasette-cluster-map", database=database, table=table)
datasette-cluster-map/datasette_cluster_map/__init__.py:        datasette.plugin_config("datasette-cluster-map", database=database, table=table)
datasette-cluster-map/datasette_cluster_map/__init__.py:        datasette.plugin_config("datasette-cluster-map", database=database, table=table)
datasette-cluster-map/tests/test_cluster_map.py:async def test_plugin_config(db_path, config, table, expected_fragments):
datasette-configure-asgi/datasette_configure_asgi.py:        configs = datasette.plugin_config("datasette-configure-asgi") or []
datasette-configure-asgi/test_datasette_configure_asgi.py:    def plugin_config(self, name):
datasette-cluster-map-old/datasette_cluster_map/__init__.py:        datasette.plugin_config("datasette-cluster-map", database=database, table=table)
datasette-auth-passwords/datasette_auth_passwords/__init__.py:    config = datasette.plugin_config("datasette-auth-passwords") or {}
datasette-auth-github/datasette_auth_github/views.py:def verify_config(config):
datasette-auth-github/datasette_auth_github/views.py:    config = datasette.plugin_config("datasette-auth-github")
datasette-auth-github/datasette_auth_github/views.py:    verify_config(config)
datasette-auth-github/datasette_auth_github/views.py:    config = datasette.plugin_config("datasette-auth-github")
datasette-auth-github/datasette_auth_github/views.py:    verify_config(config)
datasette-atom/datasette_atom/__init__.py:        plugin_config = datasette.plugin_config("datasette-atom")
datasette-auth-google/datasette_auth_google/__init__.py:    config = datasette.plugin_config("datasette-auth-github") or {}
datasette-auth-existing-cookies/test_datasette_auth_existing_cookies.py:    def plugin_config(self, name):
datasette-auth-passwords/build/lib/datasette_auth_passwords/__init__.py:    config = datasette.plugin_config("datasette-auth-passwords") or {}
datasette-annotate/datasette_annotate/utils.py:    plugin_config = datasette.plugin_config("datasette-annotate") or {}
datasette-auth-existing-cookies/datasette_auth_existing_cookies/__init__.py:    config = datasette.plugin_config("datasette-auth-existing-cookies") or {}
datasette-auth-simple/datasette_auth_simple/__init__.py:datasette.plugin_config("datasette-auth-simple")
datasette-auth-tokens/datasette_auth_tokens/__init__.py:        config = datasette.plugin_config("datasette-auth-tokens") or {}
datasette-block-robots/datasette_block_robots/__init__.py:    config = datasette.plugin_config("datasette-block-robots") or {}
datasette-block-robots/datasette_block_robots/__init__.py:    config = datasette.plugin_config("datasette-block-robots") or {}

@simonw
Copy link
Owner Author

simonw commented Nov 24, 2020

Most of these use plugin_config which is unaffected. It looks like the only code I need to worry about is this trick in datasette-graphl: https://github.com/simonw/datasette-graphql/blob/483c9a9e203bb90365def3df8b8f01dda1e75865/datasette_graphql/utils.py#L456-L460

class DatasetteSpecialConfig(wrapt.ObjectProxy):
    def config(self, key):
        if key == "suggest_facets":
            return False
        return self.__wrapped__.config(key)

@simonw
Copy link
Owner Author

simonw commented Nov 24, 2020

I'm going to make this a documented method in https://docs.datasette.io/en/latest/internals.html#datasette-class

@simonw simonw closed this as completed in f2e2bfc Nov 24, 2020
@simonw
Copy link
Owner Author

simonw commented Nov 24, 2020

simonw added a commit that referenced this issue Nov 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant