You are right, the text just above the given code sample if not request.function=='first' and not session.visitor_name: redirect(URL('first'))
was changed for the 3ed and it is wrong, it should read: "... (outside the second function)." instead of: "... (inside the second function)." Good catch! Denes On Aug 19, 7:58 am, dederocks <dediro...@gmail.com> wrote: > Hi Denes, > > Thanks a lot for the clarification. > That said, the >not request.function=='first'< part of the if > statement seems therefore useless, since this code is run only when > requesting the 'second' function. > Andre > > On 19 août, 12:55, DenesL <denes1...@yahoo.ca> wrote: > > > Hi Andre, > > > request.function has the name of the function called > > i.e. the function part inhttp://ipadr:port/app/controller/function > > > If request.function is always 'second' it means you are always > > callinghttp://yourserverip:port/yourapp/default/second > > > Hope this helps, > > Denes > > > On Aug 19, 2:33 am, dederocks <dediro...@gmail.com> wrote: > > > > Hello, > > > > I want to give web2py a try, and so experiment as I follow the online > > > web2py book. > > > Chapter 3, section 'Postbacks', code snipet: > > > > if not request.function=='first' and not session.visitor_name: > > > redirect(URL('first')) > > > > Does not appear to work as expected. request.function always returns > > > 'second'. Is this normal? My understanding was that request.function > > > should return the caller's url? > > > In other words, changing the above code to: > > > > if not request.function=='first': > > > redirect(URL('first')) > > > > Always sends you to the first page. > > > > Sincerely, > > > > Andre