Error with search action of wiki app in manual

4 views
Skip to first unread message

donnek

unread,
Jul 23, 2009, 6:01:36 PM7/23/09
to web2py-users
I'm working my way through the manual, and doing the wiki in chapter
3. Everything has worked fine (no mean feat for tutorials!), except
for one thing: the search function. The relevant lines in the
controller are:

def search():
"an AJAX wiki search page"
return dict(form=FORM(INPUT(_id='keyword',_onkeyup="ajax('bg_find',
['keyword'],'target');")),\
target_div=DIV(_id='target'))

def bg_find():
"an AJAX callback that returns a <ul> of links to wiki pages"
pattern='%'+request.vars.keyword.lower()+'%'
mypages=db(db.page.title.lower().like(pattern)).select
(orderby=db.page.title)
items=[A(row.title,_href=URL(r=request,f=show,args=[row.id])) for
row in mypages]
return UL(*items).xml()

and I think these are what the manual has on p68. The view file has:

{{extend 'layout.html'}}
<h1>Search wiki pages</h1>
[ {{=A('listall',_href=URL(r=request,f='index'))}} ]<br/>
{{=form}}<br/>
{{=target.div}}

as on p72 of the manual. But when I go to that page, I get a ticket
saying:

Traceback (most recent call last):
File "/home/kevin/revdata/downloads/webdev/web2py/gluon/
restricted.py", line 176, in restricted
exec ccode in environment
File "/home/kevin/revdata/downloads/webdev/web2py/applications/
mywiki/views/default/search.html", line 58, in <module>
NameError: name 'target' is not defined

I've been looking at this for an hour or so, and can't find any typos
in what I've done, so I wondering is there a typo in the manual?

Any advice would be very welcome. Thanks.

mdipierro

unread,
Jul 23, 2009, 8:33:25 PM7/23/09
to web2py-users
This

{{=target.div}}

should be

{{=target_div}}

could be a typo in the manual.

Massimo

donnek

unread,
Jul 24, 2009, 6:00:02 AM7/24/09
to web2py-users
> {{=target.div}}
> should be>
> {{=target_div}}

Ah, this was it - thanks.

> could be a typo in the manual.

No, to my shame the manual is correct - it was the wetware at fault!
Funny how you can't see something if you've been staring at it a
while.

Kevin
Reply all
Reply to author
Forward
0 new messages