Just for the sake of completeness modules are NOT reloaded at each http request. Modules are loaded and kept in the outer context of the interpreter at first import, unlike the request context which is rebuilt at each round by reading the models.
2017-02-06 21:48 GMT+01:00 Anthony <abasta...@gmail.com>: > On Monday, February 6, 2017 at 11:20:41 AM UTC-5, MarkEdson AtWork wrote: >> >> Also consider that every time any http request is made that all of your >> modules will be loaded. It may be helpful to use cache.ram to store your >> database connection so you can re-use it rather than creating a new >> connection to the database on each request. >> something like... >> >> self.dal_db = cache.ram('test_database', lambda: DAL( >> 'sqlite://development.sqlite'), None) >> >> > You probably don't want to do that, as the db object should be created > fresh for each request (to allow dynamic changes to model attributes that > are isolated within the request). Note, for databases that support it > (i.e., not SQLite), the DAL already maintains a cached connection pool of > connections to the database, so you won't be reconnecting to the database > on every request -- just instantiating a new DAL object and its models. > > Anthony > > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > 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/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.