[Zope] image objects into table via python script]

Cliff Ford Cliff.Ford at ed.ac.uk
Wed Nov 17 22:15:55 EST 2004


If the previous answers did not give you what you want:

You need to put the image tag in the printout:

for item in resultItems:
	print '<td>'
	print '<img src="%s" width="%s" height="%s" alt="%s">' %
(item.urloftheimage, item.width, item.height, item.caption)
	print '</td>'
         ...
return printed

Just remember that images are fetched after the page is rendered, so you
should get a page even if the image url is wrong. You need to make sure
that the query is returning your image object, not just its id.

Cliff

John Schinnerer wrote:
> Hello,
> 
> I am using a python script to generate an HTML table structure.
> The script is called from a page template, like this:
> <span tal:replace="structure
> python:container.renderTable('CatalogQueryParameter')" />
> 
> The script (renderTable) iterates over items returned from a catalog
> query which is passed one parameter.
> To put for example a date or string property in the table is easy, like
> this:
> 
> ...
> for item in resultItems:
> 	print("<td>")
> 	print(item.creation_date.strftime('%B %Y'))
> 	print("</td>")
>         ...
> return printed
> 
> What I really need to put in the table, though, are Image objects that
> are part of the objects returned.
> 
> How can I put the Image object into the table structure returned by the
> script, so that the Image object will render itself as usual?  That is,
> as it would in for example:
> 
> <span tal:replace="structure here/art_image" />
> 
> The below of course does not work (art_image is an Image object in the
> item object) - it gives a TALES attribute error on art_image:
> 
> ...
> for item in BGitems:
> 	print("<td>")
> 	print(item.art_image)
> 	print("</td>")
>         ...
> return printed
> 
> ...and I am stuck on how to get the art_image Image object into the
> table returned by the script.
> 
> 
> thanks,
> John S.
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Meet the all-new My Yahoo! - Try it today! 
> http://my.yahoo.com 
>  
> 
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )



More information about the Zope mailing list