Sorry not failing working ok this code. I have to think more about the
problem, my problem is that i want to get the response render, but my
return have to be:
d = dict(html=someinfo)
return sj.dumps(response.render(d))
this is different to:
info={}
info['html']=someinfo
return sj.dumps(info)
On Oct 6, 6:59 pm, mdipierro <[email protected]> wrote:
> Perhaps I do not understand but I do not see any problem with your
> example code below.
>
> On Oct 6, 4:44 pm, "Martin.Mulone" <[email protected]> wrote:
>
>
>
> > i see, well this "caching" method is more dangerous what i think, i
> > have to validate all the external vars, but this is my issue because
> > always have to do that :P.
>
> > Last question:
>
> > How do i do to cache render view of simple json return?.
>
> > Sample:
>
> > @cache(request.env.path_info, time_expire=CACHE_TIME_EXPIRE_JSON,
> > cache_model=cache.ram)
> > def json_get_sidebar_last_posts():
> > session.forget()
> > info={}
> > info['html']=i2p.widgets.load_last_posts()
> > import gluon.contrib.simplejson as sj
> > return sj.dumps(info)
>
> > but response.render are going to fail.
>
> > On Oct 6, 3:54 pm, mdipierro <[email protected]> wrote:
>
> > > No. This will render the page the same to all users including the
> > > welcome message. Moreover the
> > > @cache(request.env.path_info)
>
> > > will cause a vulnerability
> > > becausehttp://.../indexhttp://.../index/1http://.../index/2
> > > ...http://.../index/99999999999
>
> > > will all be cached separately and cause a memory leak.
>
> > > On Oct 6, 1:43 pm, "Martin.Mulone" <[email protected]> wrote:
>
> > > > a simple question about cache
>
> > > > if i have this in controller:
>
> > > > @cache(request.env.path_info, time_expire=CACHE_TIME_EXPIRE_PAGES,
> > > > cache_model=cache.ram)
> > > > def index():
> > > > try:
> > > > page = int(request.args[0])
> > > > except:
> > > > page = 1
>
> > > > d = dict(page=page)
> > > > return response.render(d)
>
> > > > but i have auth.navbar setting in view, this will be render
> > > > differently in each users?. I have this doubt.