Page 1 of 1

unloading a sub module?

Posted: Sat Jan 17, 2015 12:23 pm
by stonedegg
Hello, I'm currently working on a project with multiple submodules and I'm running into a problem.

Let's say I have it set up like this:

plugins/test/test.py
plugins/test/modules/module.py

And I'm importing module.py in test.py like this:

from test.modules import module

Now when I unload the main script, the unload() function in module.py won't be executed.
Is there any way I can do stuff in module.py when unloading test.py?

Posted: Sat Jan 17, 2015 12:27 pm
by Predz
Inside the "unload" function of "test.py". Just run "module.unload()".

The problem is that the only reason an "unload" function is called upon in your "test.py" file is because when you unload a add-on using SourcePython it is programmed to call them. Unlike when you import a file directly.

Posted: Sat Jan 17, 2015 12:27 pm
by Mahi
Simple solution would be to call module.py's unload() inside test.py's unload().

Posted: Sat Jan 17, 2015 12:59 pm
by stonedegg
Oh well, I could have guessed that myself.. thanks :D