473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1236
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: grz02 | last post by:
Hi, Im an experienced database+software designer and developer, but, unfortunately, anything to do with web-programming and web-systems designs is still a pretty new area to me... (been working...
4
by: Danimal | last post by:
I have been using PHP for a long time... since it was called PHP/FI. I have a programming design question: Let say I have this class: class attrib { var $lenght; var $type; ... }
2
by: Richard Stride | last post by:
I am fairly new to PHP and have written an application for managing spam in a quarantine like environment. Now the problem has arisen that Branding will eventually come into the picture as well...
36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
9
by: Sebastian Faust | last post by:
Hi, I have a design problem about which I am thinking now for a while and still couldnt find any help in deja. What I need is something like a virtual function template. I know that this is not...
12
by: Raed Sawalha | last post by:
I have the following table which i can not switcha to design view error message said Could not open in Design view. Quote values differently inside a '<% ...."value"... %>' block. and the...
17
by: Divick | last post by:
Hi, I am designing an API and the problem that I have is more of a design issue. In my API say I have a class A and B, as shown below class A{ public: void doSomethingWithB( B * b) { //do...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
2
by: King Albert | last post by:
Question : Is it 'good design' to make an eventhandler a method of your class ? Problem in the eventhandler below : I need 'this' to refer to Tabel, not to the clicked element ! ...
5
by: Fei Liu | last post by:
Hello, I have a situation where I need to design a library for multi-thread application, each thread does some work in a client supplied std::ptr_fun(free_function) or a functor. Now since it's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.