sql - I can't make a crud based search form. Why it is not working? -
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 -*- gluon.tools import crud crud=crud(dbmy) def search(): return dict(form=crud.search(dbmy.firewall))
if try 127.0.0.1:8000/[app]/select/search/firewall
url, page write this:
invalid view (select/search.html)
when controller action returns dictionary, web2y expects associated view file -- in case, /views/select/search.html. must create view.
alternatively, can enable generic.html view in case. note, in scaffolding app, generic views enabled local requests only, disabled otherwise (due security concerns).
you can specify different view via response.view
.
finally, given controller code, there no reason add "firewall" url, search
function hard coded search db.firewall
table (in fact, search
function ignores "firewall" in url).
Comments
Post a Comment