http://web2py.com/books/default/chapter/29/08?search=response.render and
http://web2py.com/books/default/chapter/29/04?search=response.render
What is not documented (feel free to send a patch for the book) is that the
view can be anything with a read() attribute....
>>> from StringIO import StringIO
>>> a = StringIO('<a>{{=test}}</a>')
>>> response.render(a, dict(test='hello world'))
'<a>hello world</a>'
so you can also avoid having n different templates (if, e.g. the template
is choosen by the user)
BTW, when you have a problem with "too many hits to the database", the
first step is to cache those queries.
VoilĂ , problem solved.
Then, enable the cacheable=True argument of select(), whenever possible
(this is just a speed improvement)
Then, if you're fetching something "fixed" just to create a view, cache the
output of response.render (so the rendering part doesn't get called over
and over)
Then - but is questionable on an app-by-app basis - you can avoid sending
to the browser over and over the same data, so you should use
@cache.action. @cache.action returns cache headers that save requests to
your app, but then ALL the requested page is cached into the browser of
your user.
So, you can architect a fixed layout that gets cached and load only a
fragment of the page you need (possibly using LOAD(), etc etc etc), that is
the real "dynamic" part of your webpage.
BTW, @Paolo advised you perfectly, I'm just going over the "process" from
step 0 to infinity.
PS: just a sidenote, when you cache something you must figure out also the
cache invalidation part (i.e. when the data should be refreshed), if needed
by your app.
On Thursday, June 13, 2013 8:58:33 PM UTC+2, Annet wrote:
>
> Hi Paolo,
>
> Thanks for your reply, is this documented in the web2py book?
>
>
> Kind regards,
>
> Annet.
>
--
---
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/groups/opt_out.