[Zope] getting image for a repeat item

Kevin Worth kworth at engin.umich.edu
Fri Jan 30 14:03:18 EST 2004


Hello-

I'm moving from dtml to ZPT on my site and have hit a snag.

I have a MySQL staff database with generic info (firstname, lastname, 
etc.).  Each staff member's photo is stored in the ZODB, in a photos 
folder at the root level.  All photos take the form 
firstname_lastname, so in dtml I can say <img src="/photos/<dtml-var 
fistname>_<dtml-var lastname>">

I've worked out the code for getting the info out of the MySQL database:

<div tal:repeat="adminstafflist container/get_tech_staff">
<span tal:replace="adminstafflist/name_first">first name</span></div>

  which is straightforward.

How would I get the image from the photos folder to display, so that 
it will get the correct photo?

I can use <img src="dummy.jpg" width="120" tal:attributes="src 
string:${root/photos/Kevin_Worth/absolute_url}">   to get my picture 
for everyone, but I need to know how to replace Kevin_Worth with the 
firstname_lastname of the repeat element.

I suppose I could add a field to my database that would contain the 
location of the photo, but it seems that I shouldn't have to do it.

Thanks for any pointers.

Kevin



More information about the Zope mailing list