[web2py] Re: read once definitions - development vs. production

2011-12-11 Thread Vineet
As Anthony pointed out rightly, if you need that module for a specific app, then put it in modules folder. If that module is required to be imported in other apps as well, then put it in site-packages folder. HTH -- Vineet On Dec 11, 9:29 am, Constantine Vasil thst...@gmail.com wrote:  I just

[web2py] Re: read once definitions - development vs. production

2011-12-11 Thread Anthony
On Saturday, December 10, 2011 11:29:49 PM UTC-5, Constantine Vasil wrote: I just put my classes in site-packages/models.py and the 'from models import *' made the classes available globally. So if I put them in /modules/models.py it would be the same? It should work the same -- let us

[web2py] Re: read once definitions - development vs. production

2011-12-11 Thread Constantine Vasil
Thank you, I tested it and it works both ways.

[web2py] Re: read once definitions - development vs. production

2011-12-11 Thread Constantine Vasil
Just to confirm: If I put a code in /modules folder is it imported every time on each function request? I want it imported on demand only when I need it.

[web2py] Re: read once definitions - development vs. production

2011-12-11 Thread Massimo Di Pierro
No. code in models is executed at every request. Code in modules is importent only once and cached. It is executed when functions in the module are called (as in normal python). On Dec 11, 2:51 pm, Constantine Vasil thst...@gmail.com wrote: Just to confirm: If I put a code in /modules folder

[web2py] Re: read once definitions - development vs. production

2011-12-11 Thread Constantine Vasil
Thank you , Massimo!

[web2py] Re: read once definitions - development vs. production

2011-12-10 Thread Constantine Vasil
Hi Vineet, Thank you! Absolutely - you understood my question properly. It seems that solution is very simple, I am so overwhelmed with this porting that sometimes I oversee the simplest solutions ;) So if I put it under site-packages like this: site-packages/models site-packages/definitions I

[web2py] Re: read once definitions - development vs. production

2011-12-10 Thread Anthony
You should be able to do the same from the application's /modules folder. Use site-packages if it's a module that needs to be accessed by multiple applications (or possibly by other Python programs). Anthony On Saturday, December 10, 2011 7:09:32 PM UTC-5, Constantine Vasil wrote: Hi Vineet,

[web2py] Re: read once definitions - development vs. production

2011-12-10 Thread Constantine Vasil
I just put my classes in site-packages/models.py and the 'from models import *' made the classes available globally. So if I put them in /modules/models.py it would be the same?

[web2py] Re: read once definitions - development vs. production

2011-12-09 Thread Vineet
@Constantine Vasil I had a similat task earlier. I am using a third party library named 'DABO'. Placed that in 'site-packages' folder within 'web2py' (source) imported that in models controllers as required. (Before that, I had tried placing it in 'modules' folder, but could not import in

[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
You can move code to modules if you don't want it all executed on every request. In that case, you'll either have to use the 'current' object or pass global objects (such as 'db') to your module functions and methods. See

[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
BTW, do you have a large number of model definitions? Have you measured the performance hit? It might not be that big. Another option is conditional models: http://web2py.com/book/default/chapter/04#Workflow. You can define models that execute only for a particular controller and even a

[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Constantine Vasil
I tried to move to modules but got the following issues: This is not possible - e.g. to acces the class directly without a prefix - when I have a lot of code if I cannot do that it is a lot of work adding a prefix. myclass = MyClass.profile(id) name = myclass.name Also if I have several

[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Constantine Vasil
They are a lot of model definitions - it is a big project which I am porting to web2py. Django templates were easy to translate. GAE working with web2py - took me a lot of time be I did it. Making the PyDev+Ecilpse+GAE SDK environment to work with debugging - very hard but it is done. Now the

[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
On Thursday, December 8, 2011 6:22:31 PM UTC-5, Constantine Vasil wrote: I tried to move to modules but got the following issues: This is not possible - e.g. to acces the class directly without a prefix - when I have a lot of code if I cannot do that it is a lot of work adding a prefix.

[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Constantine Vasil
OK let put it in reverse - how you would do this (GAE)/ in default.py myaccount = MyAccount.get_profile(user_id) Please note that 'in module' root = MyAccountRoot.get_profile() does not works - it says 'not available' or something. in default.py to import custom import

[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
On Thursday, December 8, 2011 9:29:42 PM UTC-5, Constantine Vasil wrote: OK let put it in reverse - how you would do this (GAE)/ in default.py myaccount = MyAccount.get_profile(user_id) What happens when you do: from module_that_defines_MyAccount import MyAccount myaccount =