Hello again,
I'm pretty sure the first should be like this :
**********
def first():
if request.vars.visitor_name:
session.visitor_name = request.vars.visitor_name
redirect(URL('second'))
return dict(form=form)
**********
NOTICE THE return dict(form=form), I think it's what is missing at
this step in the book (one page later it's corrected with the
FORM(INPUT()) form creation technic.
I'm kind of a newbie too but I guess without this it's not really
postingback (?)
If it works for you we should try to be sure Massimo gets the error-
reporting (so newbies don't get lost ;-)) to gather some kind of
"erratum".
Cheers,
On 31 jan, 16:33, Benjamin <[email protected]> wrote:
> Hi,
>
> I did the tutorial of the pdf last week (newest pdf of december) and
> there is a missing step exactly at this spot of the PDF. (or actually
> a "not so clear change which needs to be made to run the tutorial
> without any issue"). I didn't know of the google groups at that time
> so I didn't post the issue here...
>
> I can't remember exactly how I solved it but if you look at the steps
> very precisely you'll find the issue.
>
> Cheers,
>
> On 31 jan, 07:57, llanitedave <[email protected]> wrote:
>
>
>
>
>
>
>
> > I just downloaded web2py, and I'm going through the html book for the first
> > time. I'm just getting to the point where I think I can understand the
> > web2py approach, and I'm starting to get enthused.
>
> > I've gotten as far as the Postback section, and I'm running into problems.
> > The code does not seem to be working as posted, and I'm kind of at a loss.
>
> > Using the code below:
>
> > def first():
> > if request.vars.visitor_name:
> > session.visitor_name = request.vars.visitor_name
> > redirect(URL('second'))
> > return dict()
>
> > def second():
> > return dict()
>
> > "default/first.html" view:
>
> > {{extend 'layout.html'}}
> > What is your name?
> > <form>
> > <input name="visitor_name" />
> > <input type="submit" />
> > </form>
>
> > "default/second.html" view
>
> > {{extend 'layout.html'}}
> > <h1>Hello {{=session.visitor_name or "anonymous"}}</h1>
>
> > (I first tried it slightly customized, then in frustration I copied and
> > pasted verbatem without a change in results), it works as long as I
> > actually input the visitor_name. But if I don't input any value, then it
> > does not display "Hello anonymous" as it should. It just resets back to
> > "first.html".
>
> > I went a little further, to the next step down, but I had similar problems
> > there. It doesn't seem to be treating null session data as it should.
>
> > So what should I try next? I'll settle for any hint I can get.
>
> > *
> > *