Files in the /models folder are executed by the framework in a prepared environment, so they are not to be imported (i.e., they are not standard Python modules). Same goes for controllers. If you want to create a Python module and import it, put it in the /modules folder or anywhere on the PYTHONPATH. Note, model files are executed in alphabetical order. For more details, see http://web2py.com/books/default/chapter/29/04#Workflow.
Anthony On Monday, June 17, 2013 8:06:01 AM UTC-4, Apoorve Mohan wrote: > > Hi > > The problem with modules is solved. I was missing __init__.py file. But > how to import files present in models in db.py. This is still unclear. > > -- > Thanks > > Apoorve > > On Monday, June 17, 2013 1:23:57 PM UTC+5:30, Apoorve Mohan wrote: >> >> Hello All >> >> In my applications i have several files present in models. I need to >> import this helper.py file in my db.py. >> So in db.py i have written "from helper import get_config_file" >> But when I do so it always gives an import error: >> >> *<type 'exceptions.ImportError'> No module named modules.helper* >> >> Now the question is why is it trying to locate my file in modules folder >> instead of models. Shouldn't it just pick it up from models as they are in >> same folder. >> >> I also placed this helper.py file in modules and restarted the server but >> still it gave the same error. Why is this happening? Please let me know >> what wrong I am doing. >> >> -- >> Thanks >> >> Apoorve > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.