I have split the code into multiple files. I have imported all the functions from all other files into admin.py. Lets say I want to call a function XYZ. If I give path to function as admin/XYZ it gives me error as invalid function and for this I have to give the path as file_with_XYZ_function/XYZ.
Is there a way to overcome this problem and simple call all the imported functions from one single file
NOTE: This might not be answering your question as I’m not sure I understand your question…
But if you want to put some code into a (shared) module and include it from several of your controllers I suggest that you have a look at chapter four (The Core) of the web2py book and search for
local_import.The import of modules depends on the modules and where web2py can find them. If it is a standard module which web2py can find in sys.path or in web2py/site-packages
import modulenameshould work as expected.For modules local to your app web2py offers something else:
applications/appname/modulesThose modules can be imported using
local_import.mymodule = local_import(themodule)This imports the module with the name themodule in the apps local modules folder and makes it available under the name mymodule. Note that local_import supports two additional arguments: reload and app. During development module code often changes so don’t forget to tell web2py to reload the module upon each request with the parameter
reload=True, otherwise you won’t see your changes unless you restart web2py.