469,923 Members | 1,199 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

Design problem, call function from HTML?

This is the python way i have.

imgref = 'image.py'
out.write('<img src="%s">'
% (imgref)
in ASP.NET u can do something like this

<img src="<%# image() %>">

//allready loaded data
data

image(){
return data.img
}

Is there any remote possibility u can pulloff the same in python? Now
i have to process my data to display page and do it again to generate
my image (execute same code twice).

One solution would be to save the image to harddisk and then load it.
But rather keep it clean as return value.
Jul 19 '05 #1
1 1181
bart wrote:
(...)
Is there any remote possibility u can pulloff the same in python? Now
i have to process my data to display page and do it again to generate
my image (execute same code twice).

One solution would be to save the image to harddisk and then load it.
But rather keep it clean as return value.


something like Cheetah might help here:
from Cheetah.Template import Template
t = '<img src="$image">' data = {}
data['img'] = 'foo.jpg'
def image(): return data['img'] .... T = Template(source=t, searchList=[{'image':image}])
T <img src="foo.jpg">

....or you can access "img" directly in the template:
t = '<img src="$image.img">'
data = {}
data['img'] = 'foo.jpg'
T = Template(source=t, searchList=[{'image':data}])
T <img src="foo.jpg">

say that "data" changes, you don't have to compile the template
again, just issue a render command again:
data['img'] = 'BAZ.jpg'
T

<img src="BAZ.jpg">
see:
<http://cheetahtemplate.org/>

--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

43 posts views Thread by grz02 | last post: by
4 posts views Thread by Danimal | last post: by
2 posts views Thread by Richard Stride | last post: by
36 posts views Thread by Andrea Griffini | last post: by
9 posts views Thread by Sebastian Faust | last post: by
12 posts views Thread by Raed Sawalha | last post: by
17 posts views Thread by Divick | last post: by
reply views Thread by YellowFin Announcements | last post: by
2 posts views Thread by King Albert | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.