Use case:
I have a piece of data stored in the program node’s data model that needs to be unique for a program— it’s a path to an image stored locally where each image needs to be unique. So in the data model, I store the path to this image.
So if I copy/paste the node, the image path is also copied. This is not the behavior I desire. I’d like to be able to copy all of the data except that image path. However when a program is loaded, I want to be able to keep that image path.
Dilemma:
I can’t distinguish between the program load state and the copy/paste state, they both show up as NodeCreationType.LOAD
Potential solutions:
#1:
Keep global state of all the image paths in use. In the program node constructor, if the context is NodeCreationType.LOAD, then check this global state. If the path is there in the global state, remove the image path from this node’s data model.
why this doesn’t work:
multiple loadings of the same program. The second loading of the program would think that every node was being copy/pasted since the image paths would already be in this global state
what I would need for it to work:
an ability to hook into some event upon program load so that I could clear out this global state
Does this exist?
or-- an ability to hook into program node removal so that I could clear this particular node’s image path out of the global state.
Does this exist? (finalize is not sufficient)
#2:
In the program node constructor, if the context is NodeCreationType.LOAD
- if the image path is not empty, create a new image path and copy the old file to it (the old file path can’t be deleted though because this could be a copy/paste situation)
problem:
this completely litters the filesystem with unused image files. this is not tenable.
So in summary–
Are there any solutions available to either
1- when the context is NodeCreationType.LOAD, to distinguish between load and copy/paste?
2- an ability to hook into some event upon program load so that I could perform an action?
3- an ability to hook into program node removal so that I could perform an action? (the finalize method is not sufficient)
Thanks