it is not useless. It works of if you run only one wsgi process but
cache lives only within the lifetime of the process.

On Feb 26, 2:32 am, szimszon <szims...@gmail.com> wrote:
> Okay. It looks good now. Thanks for the prompt replay.
>
> But if I understand well than the cache.ram is useless all the time
> apache is used?
>
> On febr. 26, 09:10, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > The fact is the web server may be restarting the process or running
> > more than one process. Apache does the same. In this case you should
> > use cache.disk, not cache.ram.
>
> > On Feb 26, 1:34 am, szimszon <szims...@gmail.com> wrote:
>
> > > Hello!
>
> > > I wonder if somebody could it confirm:
>
> > > I have a db:
> > > ------- cut --------
> > > db.define_table('guestbook',
> > >                 Field('email','string',
> > >                       label=T("E-Mail"),
> > >                       requires=IS_EMAIL()),
> > >                 Field('nick','string',
> > >                       label=T("Nickname"),
> > >                       requires=IS_NOT_EMPTY()),
> > >                 Field('ts','datetime',
> > >                       label=T("Date"),
> > >                       default=request.now,
> > >                       writable=False,
> > >                       readable=False),
> > >                 Field('text','string',
> > >                       label=T("Text"),
> > >                       requires=IS_NOT_EMPTY()),
> > > )
> > > ------- cut --------
>
> > > A controller:
> > > ------- cut --------
> > > def flush_cache(form=None):
> > >     cache.ram.clear()
>
> > > def vendegkonyv():
> > >     lista=None
> > >     if (( auth.user_id==1 ) and (request.vars.r)):
>
> > > form=SQLFORM(db.guestbook,request.vars.r,deletable=True,onaccept=flush_cach
> > >  e)
> > >     else:
> > >         form=SQLFORM(db.guestbook,onaccept=flush_cache)
> > >     #form=SQLFORM.factory()
> > >     if not auth.user_id:
> > >         form[0].append(Recaptcha(request,
> > >                                  "...",
> > >                                  "..."))
> > >     if form.accepts(request.vars, session):
> > >         response.flash = "Record updated"
> > >         flush_cache()
> > >     elif form.errors:
> > >         response.flash = "Error"
> > >         flush_cache()
>
> > >     try:
> > >         lista=db(db.guestbook.id>0).select(orderby=~db.guestbook.ts,
> > >                                            cache=(cache.ram,120))
> > >     except:
> > >         pass
> > >     return dict(form=form,lista=lista)
> > > ------- cut --------
>
> > > And a view:
> > > ------- cut --------
> > > {{extend 'layout.html'}}
>
> > > <h1>GuestBook</h1>
> > > <div>
> > > {{=form}}
> > > </div>
> > > {{if lista:}}
> > > <table class="vendegkonyv">
> > >   <tr>
> > >     <th>{{=db.guestbook.ts.label}}</th>
> > >     <th>{{=db.guestbook.nick.label}}</th>
> > >     <th>{{=db.guestbook.text.label}}</th>
> > >   </tr>
> > > {{for elem in lista:}}
> > >   <tr>
> > >     <td>
> > >       {{if (auth.user_id==1):}}
>
> > > {{=A(elem.ts,_href=URL(r=request,f='vendegkonyv',vars=dict(r=elem.id)))}}
> > >       {{else:}}
> > >         {{=elem.ts}}
> > >       {{pass}}
> > >     </td>
> > >     <td>{{=elem.nick}}</td>
> > >     <td>{{=elem.text}}</td>
> > >   </tr>
> > > {{pass}}
> > > </table>
> > > ------- cut --------
>
> > > With the cherrypy isn't a problem but with apache2 and wsgi:
>
> > > 1, I make 3-4 post to the guest book
> > > 2, delete them
> > > 3, reload the page with a link on page pointing to self to guestbook
>
> > > I see 0 to 3-4 post on each click randomly which are nonexistent posts
> > > anymore :(

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to