Reputation: 69
My code:
models/db.py
....
dbmy = DAL('mysql://user:user@localhost/test',migrate_enabled=False)
dbmy.define_table('Firewall', Field('disabled','text'),
Field('src_port_first','integer'),
Field('src_port_last','integer'),
Field('port_first','integer'),
Field('port_last','integer'),
Field('type','text'),
Field('Src_op','text'),
Field('src_ipaddr_first','text'),
Field('src_ipaddr_last','text'),
Field('src_netmask','text'),
Field('Dst_op','text'),
Field('dst_ipaddr_first','text'),
Field('dst_ipaddr_last','text'),
Field('dst_netmask','text'),
Field('Action','text'))
dbmy.commit()
controllers/select.py:
# -*- coding: utf-8 -*-
from gluon.tools import Crud
crud=Crud(dbmy)
def search():
return dict(form=crud.search(dbmy.Firewall))
If I try to 127.0.0.1:8000/[app]/select/search/Firewall
URL, The page write this:
invalid view (select/search.html)
Upvotes: 1
Views: 33
Reputation: 25536
When your controller action returns a dictionary, web2y expects an associated view file -- in this case, it will look for /views/select/search.html. You must create that view.
Alternatively, you can enable the generic.html view in this case. Note, in the scaffolding app, all generic views are enabled for local requests only, but disabled otherwise (due to security concerns).
You can also specify a different view via response.view
.
Finally, given your controller code, there is no reason to add "Firewall" to your URL, as the search
function is already hard coded to search the db.Firewall
table (in fact, the search
function completely ignores the "Firewall" in the URL).
Upvotes: 2