We have a site with thousands of product images that are supplied by a third party. In our case, the supplier FTPs the images to the filesystem of the machine where Zope runs. Whenever we render a page, we invoke a very simple external method which checks whether the image exists in the filesystem, and generates its <img> tag. If the image us unavailable, a <img> tag refering to a default image is generated. I understand your case is more complicated, because the images are in a different machine. Any way, I can send you the External method if you like. Regards, Luciano Lee Reilly CS1997 wrote:
thanks, john.
this looks like the best option. uploading the files to my zope server is not really an option. i've set up database simply recording, which files are held on the external server to help (as a short-term solution) but this would prove just as tedious in the long run and there's no way i'd include this is my final build.
so...
i checked out httplib module (HTTP protocol client) ref: http://www.gmu.edu/mlnavbar/webdev/doc-python/lib/module-httplib.html
but it doesn't seem to be supported by python methods. i've managed to create a total system so far without using any external python methods (the ones stored in an extension but this seems like the only option now.
can anyone tell me if there are any alternatives?
thanks if you can help,
lee
John wrote:
- Write an external method that goes out and checks whether the image in question actually exists on the server. You might need to do an HTTP HEAD on the expected image URL, but this is roughly what the user's browser will have to do, so it's pretty much the canonical test.
for more info on *exactly* what i'm trying to do here's a message posted this to comp.lang.python:
- sorry for the larger than normal post :-o
------------------------------------------------------------------------
Subject: retrieving file data from an external server - where to start? Date: Tue, 20 Feb 2001 16:20:03 +0000 From: Lee Reilly CS1997 <lreilly@cs.strath.ac.uk> Organization: Department of Computer Science, University of Strathclyde Newsgroups: comp.lang.python
hi there,
i'm using python with zope and am trying to do the following with python method:
retrieveFileInfo(matric){
username = getUsername(matric) filename = username + ".gif" server = "http://blahblahblah/yaddieyaddie/"
# some code to determine whether or not the file exists # where do i start # e.g if (retrieve.(server+filename) != none): # do something }
e.g. given the matric value '9728430' i find that the corresponding user has username == 'lreilly'. if this person has their image stored on the external server then it will be called 'lreilly.gif'.
i don't need to actually retrieve the file from python - only determine whether or not it exists or not. i.e. whether the http request reports a 404 or maybe even if the image size == 0 bytes.
could someone possible be kind enough to give me an idea where to start? a url? a snippet of code?
thanks very much in advance,
lee