I've started using Dogpile, first for SQLAlchemy queries although I'd like to use it more widely for things like this.
On Wed, Mar 11, 2015 at 10:02 AM, Jonathan Vanasco <jonat...@findmeon.com> wrote: > I have a few views that are high traffic and too intensive for normal > processing. I need to cache them. > > I tried an inner generator pattern for the HTML, which works well, but > generating the response is ugly: > > @view_config(route="index") > def my_view(self): > """the core data is cached within the view. > """ > @cacheable_decorator > def _generate(): > as_html = pyramid.renderers.render('/index.mako', {}, self.request) > metadata = self.request.page_metadata # add_request_method property, > details about the page > return (as_html, metadata) > (page_html, page_metadata) = _generate() > response = pyramid.response.Response( > content_type = 'text/html', > body = page_html, > status = 200, > ) > return response > > Is there a better pattern or approach for this? > > Caching views is popular in a lot of frameworks, but the only Pyramid stuff > i found were some problems on StackOverflow. > > Having to create a response -- or define a custom renderer for it -- > suggests that I'm missing something obvious. The built-in "string" renderer > won't work -- it sets a 'text/plain' header. There is no 'html' renderer. > > Anyone have advice? > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To post to this group, send email to pylons-discuss@googlegroups.com. > Visit this group at http://groups.google.com/group/pylons-discuss. > For more options, visit https://groups.google.com/d/optout. -- Mike Orr <sluggos...@gmail.com> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.