I've been testing the way you described above and it works, to a point. The models are not imported in alphabetical order. This seems to be controlled by this line (521):
models = listdir(path, '^\w+\.py$', 0, sort=False) in compileapp.py
listdir is essentially os.walk with a regexp for filtering and os.walk doesn't give any guarantees for ordering at all from what I understand.
Later in compileapp, the models found with listdir are looped through, once (not dependant on the regexp) which gives changing the regexp between models limited use.
To explain my issue, I'll try to use an example. Please bear with me!
Let's say I have the following models:
dbInterface/someDbFile.py
anotherInterface/someAnotherInterface.py
Now let's assume that listdir lists the models root dir first, then anotherInterface dir and then dbInterface dir.
I want the dbInterface to load before anotherInterface since anotherInterface is dependant on dbInterface.
So in __init__.py I do:
response.models_to_run =['dbInterface/']
And in the someDbFile.py model, I change the regexp to:
response.models_to_run = ['anotherInterface/']
This will however cause stuff in anotherInterface to never be loaded since the loop in compileapp has already passed (and filtered out) all anotherInterface files once I get to the dbInterface files.
Is there any way I can control the order things are imported from subfolders without changing web2py? I am aware that just setting sort to true in the listdir-call will fix my issue but I would like to be able to update web2py without having to make that change each time, if possible.
Best regards,
Joel