[Zope] Newbie Question: Returning random images for use in <img src=''> links on other server

Ben Chapman benjamin-chapman@utulsa.edu
Tue, 20 Nov 2001 09:56:17 -0600


Everyone:

Please excuse this if it is a FAQ; I've looked and I've got the book,
but I'm am just not getting this.

Our main web server (I can't change this) is an IIS box. I want to
generate links to random images stored within zope.

What I want to do (on the IIS box) is:

  <img src=http://myzopeserver/content/showimg>

where showimg does something like this on myszopeserver:

[BEGIN BROKEN CODE]
<dtml-call "RESPONSE.setHeader('Content-Type', 'image/jpeg')">
<dtml-var expr="_.whrandom.choice(files.objectValues())>"
[END BROKEN CODE]

In other words, I want the "raw" image data stored in one of the
random files located in the files folder to be returned. This does
not work; it seems I need the read() method of the file object, but I
don't know how to integrate that with the construct above.

Any help would be most appreciated. Sorry for the very basic question. 
We're running Zope 2.1.6 and Python 1.5.2

Ben Chapman
Director, Computing Resources, University of Tulsa College of Law
bchapman@utulsa.edu