A webpy Templetor question

Chris Angelico rosuav at gmail.com
Mon Jul 13 20:59:08 EDT 2015


On Tue, Jul 14, 2015 at 9:13 AM,  <yongzhi.chen at gmail.com> wrote:
> #in my application.py:
> def checknow():
> ...
>     return TN_str
>
> render = web.template.render('templates/',globals={'stat':checknow})
>
> #in the template:
> $def with(checknow)
> ... ...
>     <h1><div>Test: $stat(checknow)</div></h1>

You've effectively taken a reference to the checknow function and
given it the name 'stat'. So when you call $stat(), I would expect it
to call checknow() with exactly those arguments. I don't know what
"$def with(checknow)" means, but if you figure out what checknow is
inside there, then you'll know whether you want any argument at all. I
suspect just "$stat()" may well do what you want.

ChrisA



More information about the Python-list mailing list