Re: [Zope] Images from database into html
I have gained access to a employees' database which among other stuff contains employees' photos (that is, in binary form). I'm trying to display employees with their names and photos etc. HTML page looks like this: <dtml-in sql_employees> <dtml-var first_name> <dtml-var last_name> <img src="his_or_her_photo"> (which is DTML method) But it is not called!
Actually it is called. Even if object is fetched this way. I think problem was that when it was called it was not under namespace of <dtml-in sql_employees>. But I got it working now (see at the end of this mail).
What about: <dtml-var photo> Thats no good since it just prints the binary contents in the HTML page. My photos are as files, not as a filenames, in database. (I looked around a little and read that this is not good practice, but it would be very hard for me to do something about it).
Ok, here is what I did. Database has these fields: person_id, first_name, last_name, photo. <dtml-in sql_employees> <dtml-var first_name> <dtml-var last_name> <img src="persons_photo?person_id=<dtml-var person_id>"> </dtml-in> persons_photo is DTML method: <dtml-in sql_photo><dtml-var photo></dtml-in> (no linefeeds or spaces between since it would mess up the file and would be interpreted incorrectly) sql_photo is SQL method, which takes attribute: person_id. SELECT photo FROM employees WHERE person_id=<dtml-var person_id> Sven Syld
participants (1)
-
Sven Syld