【发布时间】:2021-03-26 14:59:50
【问题描述】:
如果你有这样的控制器方法:
@expose('example.templates.example.index')
def index(self, *args, **kw):
fruits=session.query(model.Fruit).all()
# some code working on fruits
return dict(fruits=fruits)
如何复制相同的 html 渲染方法,但使用过滤对象,例如示例
@expose('example.templates.example.index')
def filtered(self, name="apple", *args, **kw):
fruits=session.query(model.Fruit).filter_by(name=name).all()
# some code working on fruits (same as in index)
# how to not duplicate the code but duplicate method with different input fruits?
return dict(fruits=fruits)
如何不复制代码而只复制具有不同输入结果的方法? 我希望有单独的端点工作相同但过滤输入。
【问题讨论】:
标签: python turbogears2