views/item/index.html:
{{extend 'layout.html'}}
<h1>This is the item/index.html template</h1>
{{=LOAD(request.controller,'p_view_list.load')}}

views/p_view_list.html:
{{extend 'layout.html'}}
<form enctype="multipart/form-data" action="" method="post">
...
</form>

controllers/item.py:
def p_view_list():
    for k,v in request.vars.items():
        if k.startswith('need_'):
            id = k.split('_')[-1]
            item = db(db.Item.id == int(id)).select()[0]
            item.update_record(need=('on' in v))
        response.flash = "Saved"
    items = db(db.Item.category==db.Category.id).select(db.Item.ALL)
    #since this is ajax, this causes the response to get displayed
    if response.flash: response.headers['web2py-component-
flash']=response.flash
    return dict(items=items)

http://127.0.0.1:8000/list/item/p_view_list.load - works fine - I see
the form.  .json also works.
http://127.0.0.1:8000/list/item/index - broken - It displays "invalid
function"

Any ideas why it displays 'invalid function'?

Also, If I change the LOAD statement to:
{{=LOAD(request.controller,'p_view_list')}} (and remove the 'extend
layout.html' line) it loads fine.

I asked this before, but what is the difference between the two?



Reply via email to