There are two ways to import modules. 1) The standard Python way: If you install modules in a place where pyhon can find them (in sys.path) then you just import them as you would normally do in Python
form youmodule import something 2) The "additional" web2py. If a module is in a place that is not in the python path then you have to specifiy the path. For example if the module in in the appliance: from applications.appname.modules.yourmodule import somthing since occasionally you do not know the name of the app then you do exec('from applications.%s.modules.yourmodule import somthing' % request.application) We could add, by default, the applications.*.modules paths to sys.path but then conflicts between different apps may arise if two apps have modules with the same name. This is due to the fact that Python has a global sys.path not a thread safe path. On Aug 12, 6:48 am, Ahmed Soliman <ah...@farghal.com> wrote: > Hello everybody, > > After reading about importing modules in web2py I feel not satisfied > regarding the way I import modules from the modules directory because I have > to specify the application name in the import statement, the other ways are > hackish and are painful if you are doing lots of imports. > > Another issue is that. I want to add classes and new validators to my code, > where should I put that? model was the best place so far because when I > change my code in those classes I don't have to restart the python instance > so web2py can see my changes as the case in modules/ > > But the problem is that in model/ I cannot import other modules from the > same package *model* is there a nicer way to organize my stuff in a way > that's more intuitive? > > Best Regards, > > Ahmed Soliman > Software Engineer > B-Virtual Team. > > Thebe Technology. Egypt - Belgium > 16 Nehro St. Heliopolis. Cairo > Egypt. > > http://www.b-virtual.orghttp://www.thebetechnology.com > > GPG ID: 0xAEEE5042 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---