web.py在note页面中应该如何接收值的传入,web.pynote,在code.py中声明如


在code.py中声明如下数据库对象

db = web.database(dbn='mysql' , user='root' , pw='jackniang#2',db='YoO_database')

将数据库对象return到index.html模板

class index:def GET(self):notes = db.select('tab_note')return render.index(notes)

在index模板中接收

$def with (notes)

在页面遍历并通过超链接方式将单个记录结果传递给notepage页面

$for note in notes:<a href="/note?$note" >

请问,在note页面中应该如何接收?我已经试过用字典形式但是不行。

note 页定义一个新的路由

urls = (    '/', 'index',    '/note/(.*)', 'Notepage'  # 超链接传入note)

然后在Note控制器中获得地址栏传入的id

class Notepage:    def GET(self, note):        return render.notepage(note)

这样就能在notepage.html这个模板中调用了,跟你的index差不多

编橙之家文章,

评论关闭