Storage is saved with .toe and .tox files and is loaded on startup.
and I got it to work correctly in a test .toe file. I store an object in a tox with some parameters, I link these parameters within the tox, and am able to change these parameters on the fly by manipulating the stored object. As I would expect, if I “reload” the .tox, the edits I made dissappear, and the tox gets reloaded with the initial stored values.
However, if I load the same tox in another .toe, there is no object saved inside it. So I’m wondering if the data is saved in the toe with reference to the tox, and if loaded in another toe, the data is lost.
I also tried restarting the toe, hoping that “startup” would magically make the object reappear, with no avail.
I am struggling to understand if this is a bug or if I’m understanding it wrong.
Storage is saved with the node that it is part of. So if that node is part of the tox file then it will be inside the tox file.
However, there might be some complications when using externals because you can end up with multiple copies of that tox node that could potentially have different storage data depending on when they were saved i.e. the toe file will have a copy of the node including any storage in it and the tox will also have a copy with the storage. When you hit reload, it should replace the version in the toe file with whatever was in the tox file.
Hope that makes sense. I did some quick re-testing here with a simple tox and the storage data was present in any toe file I loaded it into.
If you want to share your test project I can take a look to see if there is anything different going on in your case. You can post files here or send them to support@derivative.ca
Super simple toe with tox file. Tox file behaves correctly in this toe, Everytime I reload the tox, I can see the stored object, and the parameter is fetched inside the tox correctly.
As soon as I drop the tox in a new toe file, no object is found.
Thanks for the example. That makes it a lot clearer.
The problem is that the tox is trying to store a custom defined object, but when it is reloaded into the new toe file the class definition of that object is no longer available and so python doesn’t know how to decode it from storage.
Unfortunately, there isn’t really a good fix for this because custom python objects rely on an internal absolute network path back to the DAT that defines them i.e ‘project1/store_stuff’ in your case. If that same DAT is in the new file, then it should work, but otherwise it will fail.
If you want to save custom objects into portable tox files, the best option might be to add a custom save/load method to your class that only uses simple types like ints, arrays, dicts, etc which can always be fetched safely.
I hope that makes sense. Let me know if you have any questions.
Thanks for this @robmc ! That makes sense now that you explain it.
In my actual project, I have everything inside extensions, so I’ll do some tests to see if it works assuming that the custom defined object is within one of the extensions loaded on startup.