Page 1 of 1

Some more unload/load suggestions/changes

Posted: Fri Jul 20, 2012 11:06 pm
by Omega_K2
Loading (and unloading) subscripts does not seem to work at the moment.

Expected way to load subscripts:

sp_load main/sub

This is trying to load:

main/sub/main/sub.py

Should be:

main/sub/sub.py

Syntax: Select all

# item = cmd argument
path = item + '/' + item.rsplit('/',1)[-1] + '.py'
importstr = item.replace('/','.') + '.' + item.rsplit('/',1)[-1]


EDIT:

Also if your addon happens to have the same name like an internal/python module you won't be able to load it. I think this should be somehow prevented or so, because it may cause confusion on the user side because you'll just get an import error :P

Posted: Sat Jul 21, 2012 12:13 am
by satoon101
Correct, I have designed the load/unload section so that if a script wants to load its own subscript, it will need its own API to do so. This is the correct way to handle this, imo.

I have noticed that import error issue, as well, since I can no longer use test as an addon. I'm not sure if we even plan at any point to change that, but I doubt we do as it would likely get too complicated.

Satoon

Posted: Sat Jul 21, 2012 12:45 am
by Omega_K2
satoon101 wrote:Correct, I have designed the load/unload section so that if a script wants to load its own subscript, it will need its own API to do so. This is the correct way to handle this, imo.


I partially argee, but those subfolders can also used to structure scripts further.

For example, when working on the auth stuff I had the idea to put all auth providers in their own subfolder. Obviously each auth provider is independent from each other, but still I think this:
auth_providers/simple
auth_providers/group
auth_providers/mysql
is better compared to:
simpleauth
groupauth
mysqlauth

Another example would be the now obsolete corelib. I still see some use in having this.

satoon101 wrote:I have noticed that import error issue, as well, since I can no longer use test as an addon. I'm not sure if we even plan at any point to change that, but I doubt we do as it would likely get too complicated.


Possibly the output could be changed sightly, so it's the error + "[SP] Note: Check whether your addon has the name of an existing module". I think that might help with confusion

Posted: Sat Jul 21, 2012 1:01 am
by satoon101
That is a good idea for the error, I'll look to adding that when I get the chance.

Thank you,
Satoon

Posted: Sun Jul 22, 2012 2:43 am
by satoon101
I'm still thinking of how best to let the server know which Auth provider is being used, but that will partly depend on the final build of the Auth API. I don't think, at this point, that I want them to be "scripts". They should be within the Auth API, somewhere. I just am not sure how to load the one the server is supposed to be running. One idea is that we can use an .ini file for some things of this nature that should never be changed while the server is running. That way, when the server loads, it reads the .ini to know (in this instance) which Auth provider to use, and loads it.

Satoon

Posted: Mon Aug 05, 2013 2:30 am
by Omega_K2
Sorry for the necro, but I still think you should be able to load scripts in a sub folder.

Simply because of script collections and organizing your folder structure.
For example, I think this:
k2tools/examples/myexample/myexample.py
k2tools/examples/myexample2/myexample2.py
k2tools/examples/myexample3/myexample3.py
k2tools/anotherthing/anotherthing.py

is much better directory structure then:
k2tools_myexample1/k2tools_myexample1.py
k2tools_myexample2/k2tools_myexample2.py
k2tools_myexample3/k2tools_myexample3.py
k2tools_anotherthing/k2tools_anotherthing.py

You pretty much avoid spamming the main folder also, if you write a bunch of stuff.

Especailly if these scripts have not that much do with another, a custom loader, which also has to be maintained speratly, seems pretty bad to me. After all, you can still use a custom loader if you need one.

Posted: Tue Aug 06, 2013 2:25 am
by satoon101
Nope, not gonna happen. It is the job of the script itself to load/unload its own sub-modules. This will not change. If the scripts don't have much to do with one another, then they should be separate scripts.

Satoon