Import Web2py once per session

I use Web2Py and I want to import my program only once per session ... not every time the page loads. Is it possible? for example, the "import client" that is used on the page, but import it only once per session.

+4
source share
1 answer

In web2py, your models and controllers are executed, not imported. They are executed every time a request arrives. If you click the [compile] button in admin, they will be compiled bytecode and some other optimizations will be performed.

If your application (in models and controllers) performs "import somemodule", then the import statement is executed for each request, but "somemodule" is actually imported only at the first start, as you requested.

+6
source

All Articles