home / docs / sections

sections: internals:internals-utils-call-with-supported-arguments

This data as json

id page ref title content breadcrumbs references
internals:internals-utils-call-with-supported-arguments internals internals-utils-call-with-supported-arguments call_with_supported_arguments(fn, Call fn , passing it only those keyword arguments that match its function signature. This implements a dependency injection pattern - the caller provides all available arguments, and the function receives only the ones it declares as parameters. This is useful in plugins that want to define callback functions that only declare the arguments they need. For example: from datasette.utils import call_with_supported_arguments def my_callback(request, datasette): ... # This will pass only request and datasette, ignoring other kwargs: call_with_supported_arguments( my_callback, request=request, datasette=datasette, database=database, table=table, ) datasette.utils. call_with_supported_arguments fn ** kwargs Call fn with the subset of **kwargs matching its signature. This implements dependency injection: the caller provides all available keyword arguments and the function receives only the ones it declares as parameters. Parameters fn -- A callable (sync function) kwargs -- All available keyword arguments Returns The return value of fn ["Internals for plugins", "The datasette.utils module"] []
Powered by Datasette · Queries took 23.779ms