Variables : Comp Python Storage VS Mod Class >> Interference?

Hi,

I’m refactoring an old project from 2016, and I encountered an issue. Back then, Python storage wasn’t available (as far as I remember), so I used a localCOMP containing a variablesDAT and a modulesCOMP to store variables.

Now, I’m trying to upgrade the workflow by storing all variables in the parent component’s storage. While the variables do appear in the parent storage (visible via the Examine DAT or the Customize Component dialog), I can’t fetch them using fetch(). I keep getting an error stating that the fetched items can’t be found.

Interestingly, if I manually store a dummy variable (one that isn’t part of local/variables or modules), I can fetch it successfully.

Could this issue be related to how variables imported via the mod class interact with Python storage?

best,

Hi @pixelux,

could you post a small reproducible example?

cheers
Markus

Hi Markus, @snaut

yes, here it is :
demo_ModvsStorage.toe (8.0 KB)
I made a fresh comp but the same issue


variables included in the local/modules will raise an error

best

Just gonna jump in here and highly recommend that you take a look at Extensions, which are the bestPractive nowdays to handle this kind of behaviour.

Hi @pixelux,

main issue in the example is that the key ‘media’ actually has a space at the end. So when you try:

print(me.fetch('media '))

it will return the saved path.

cheers
Markus

Hi Markus,

Sure, It cannot work :nerd_face:
sorry for the false alarm and thanks to checking it.

Hi @alphamoonbase

What do you mean by this behaviour?
For data storage?
I don’t see how extension could help, but truly interested to know how I could use extension for this purpose.
My concern is that I never store any data inside the main .toe file or external .tox, if possible.
By data I mean configuration parameters, which could be float, int, str …
Maybe it is a weird workflow, but all data is stored in .dat on disk.
I use tableDAT to sync to the file and a script to store and update the data in the root component python storage.

The reason I process like this is I would rather not have to save the whole toe file or external component if any data is changed.
A bit like how you could also externalize python script for versioning.
For more complex python object, I may use a base component to store the data .

Thanks