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 http://web2py.com/book/default/chapter/04#Accessing-the-API-from-Python-modules.
Anthony On Thursday, December 8, 2011 5:30:12 PM UTC-5, Constantine Vasil wrote: > > I used the PyDev+Eclipse+ GAE debugger extensively (after making it > working) > to see how web2py is working internally. > > Bottom line web2py is excellent for rapid development - while it is still > running, > any change in the model in 0.py (say) is available immediately after > browser refresh > because 0.py is read every time on browser refresh. > > This is perfect for development but for production kills the speed. > Actually after 0.py > is tweaked and reaches maturity I need to put it at read 'once mode'. > > This is much more important with GAE because for GAE you update all your > project > on the cloud, not just 0.py if changed, so this feature is useless for GAE > in production > environment and slows down the execution. > > In 0.py I have GAE models which are already stable and I have to be able > to put them > in a read once place. The question is how they would be available globally > too? > In ideal scenario if I have a class: > > class MyClass(db_google.Model) > name = dg_google.string(...) > def profile(self, id) > <some code> > > I would want to access the model like (the simplest possible way): > > myclass = MYClass.profile(id) > name = myclass.name > > > Is this possible in web2py? > > Regards, > --Constantine > > > > > > > >