On Friday, February 23, 2018 at 10:29:32 PM UTC-5, 黄祥 wrote: > > according to book : > http://web2py.com/books/default/chapter/29/04/the-core?search=response.render, > > the response.render is used in controllers, let say, my controller is > contain nested loop and i decide to put it on views, but i don't want to > lose the web2py cache function > *e.g.* > *controllers/default.py* > @cache.action(time_expire = cache_time_expire, cache_model = cache_model, > quick = cache_quick, prefix = cache_prefix) > def report_bank(): > rows_currency = db(db.currency.id > 0).iterselect() > return dict(rows_currency = rows_currency) >
The @cache decorator will cache the output of the decorated function. In the above case, it will cache the returned dictionary, but I'm not sure this makes sense with .iterselect() -- you should probably instead use .select() if you want to cache the results of the query. In that case, the view will still be executed on each request. If you also want to cache the generated view, then return response.render(...) instead of the dictionary. 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

