开发者

Is passing ORM entities into templates acceptable in MVC pattern frameworks?

Is passing ORM entities directly into templates acceptable?

In a hypothetical python framework is this worse

def fetch开发者_运维问答_widgets:
    widgets = widget.fetch("price < 50")
    render_template('widget.html', widgets=widgets)

than this?

def fetch_widgets:
    widgets = [(w.name, w.price) for w in widget.fetch("price < 50")]
    render_template('widget.html', widgets=widgets)


If the template engine is only capable of retrieving models, then sure. It's when templates are used to manipulate models that the walls break down.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜