How about: return response.render(dict(pledges=pledges))
An alternative is just to cache the select instead of the whole view: pledges=db((db.pledge.segment==segment_id) & (db.pledge.read == False)).select(orderby=~db.pledge.created_on, cache=(cache.ram, 5)) In that case, you would remove the @cache decorator from the function. See http://www.web2py.com/book/default/chapter/06#Caching-Selects. Anthony On Tuesday, November 22, 2011 10:25:22 AM UTC-5, johntynan wrote: > > I am using the following decorator: > > @cache(request.env.path_info, time_expire=5, cache_model=cache.ram) > > To cache some db queries, however, when I go to deploy this on Google > App Engine, I receive a "PicklingError: Can't pickle <type > 'function'>: attribute lookup __builtin__.function failed" You can see > the traceback here: > > https://gist.github.com/1384892 > > I have a feeling the error has to do with caching a for loop in a > view. You can see the view here: > > > http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/views/refresh/thank_yous.html?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11&r=f8cd17ed0367521b8bd726c48ac829e920207c11 > > You can also see the "thank_yous" function here: > > > http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrives/controllers/refresh.py?spec=svnf8cd17ed0367521b8bd726c48ac829e920207c11&r=f8cd17ed0367521b8bd726c48ac829e920207c11#74 > > I think the solution lies with creating the view within the function > using return response.render() as described in the web2py book here: > > http://www.web2py.com/book/default/chapter/04?search=cache+view > > but I'm at a loss for how to do this. Does anyone have any clear > examples for using response.render and an html template. > > Thanks! > >