auth.wiki and components error:list index is out of range

37 views
Skip to first unread message

Philip Lutz

unread,
Aug 5, 2013, 4:35:37 PM8/5/13
to
I have walked through the component example in the book, and am now attemmpting to get this to work on a wiki page.
The first setup works
 
In default.py

 

 
def index():
# return auth.wiki()
return dict()

def post():
findname = request.args[0]
return dict(specs=db(db.specs.name==findname).select())


        
In default/index.html
{{extend 'layout.html'}}                          
{{#=content}}                          
{{=LOAD('default','post.load',args=['merlin'],target='spec',ajax=True)}}

In views/default/index.html
{{extend 'layout.html'}}                       
{{#=content}}                       
{{=LOAD('default','post.load',args=['merlin'],target='spec',ajax=True)}}

In views/default/post.load
{{#extend 'layout.html'}}                    
{{for row in specs:}}                    
<div>                    
<table border="1">                    
<tr><td colspan="2">Specifications</td></tr>                    
<tr><td>Aircraft</td><td>{{=row.name}}</td></tr>                    
<tr><td>Wing Span</td><td>{{=row.wingspan}}</td></tr>                    
</table>                    
</div>                    
{{pass}}

The Page shows correctly, and when I view the page source I see;
…                   
<script type="text/javascript"><!--                   
web2py_component('/test/default/post.load/merlin','spec');                   
//--></script><div id="spec">loading...</div>                   
…                   
                   

Now I change to the wiki style
 
In default.py
def index():                
  return auth.wiki()                
#  return dict()                
                
def post():                
findname = request.args[0]                
return dict(specs=db(db.specs.name==findname).select())

In views/default/index.html
{{extend 'layout.html'}}         
{{=content}}         
{{#=LOAD('default','post.load',args=['merlin'],target='spec',ajax=True)}}

Index Wiki page has this content
## Index      
page content      
[[NEWLINE]]      
@{component:LOAD('default','post.load',args=['merlin'],target='spec',ajax=True)}

 
and now the page shows
 
Index     
Page content     
ERROR: list index out of range

 
What am I doing wrong?
 
Thanks,
 
Phil
 

Alan Etkin

unread,
Aug 5, 2013, 8:41:58 PM8/5/13
to
> @{component:LOAD('default','post.load',args=['merlin'],target='spec',ajax=True)}

I belive that line should be

@{component:default/post.load/merlin}

Alternatively you could use

@{component:URL('default','post.load',args=['merlin'])}

EDIT: the alternative way is wrong. In fact it fails with the same error as if LOAD was used.

Philip Lutz

unread,
Aug 5, 2013, 5:00:54 PM8/5/13
to web...@googlegroups.com
Excellent.
This worked like a dream.
 
As this is my first week with Web2Py, I am struggling a little.
Great to know that there are others out there to assist.
 
Thanks again,
 
Phil

Alan Etkin

unread,
Aug 5, 2013, 5:23:38 PM8/5/13
to web...@googlegroups.com
Great to know that there are others out there to assist.

Good to know it worked. IMO the book is the best reference for those starting but you can always ask for help in case your're stuck.
Reply all
Reply to author
Forward
0 new messages