pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

Reference docs appear to be wrong about config deprecation.

Open fireboy1919 opened this issue 2 years ago • 2 comments

Found this line:

Note that accessing pyscript.config["apps"] is deprecated. The apps entry will be removed in a future release so that apps do not have access to another app’s configuration (which might include token, passwords or keys).

Using the latest version of pyscript, I did a debug log of the pyconfig from my trigger which is stored in an app. The only config available is the one from within apps. I cannot access any of the variables that should be local to the app directly from pyscript.config["varname"]

fireboy1919 avatar Feb 27 '23 01:02 fireboy1919

An application's config should be available via pyscript.app_config["varname"]. Note that that variable is only available in the app's context (ie, apps/app_name.py or apps/app_name/__init__.py).

craigbarratt avatar Feb 28 '23 07:02 craigbarratt

I think perhaps I wasn't clear.

When a trigger created within apps/app_name.py runs,

The only way to retrieve the config that actually works is to access pyscript.app_config["apps"]["app_name"]["varname"]

The referenced way doesnt actually work.

I assume that this is because triggers don't actually get app scoping to allow them to see their app's config.

fireboy1919 avatar Mar 03 '23 03:03 fireboy1919