[Zope] httplib (was re:throwing exceptions when <img src=...> does not exist)

Lee Reilly CS1997 lreilly@cs.strath.ac.uk
Tue, 20 Feb 2001 16:42:06 +0000


This is a multi-part message in MIME format.
--------------0CB8D9E42B1C70A4F8BE2724
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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
--------------0CB8D9E42B1C70A4F8BE2724
Content-Type: message/rfc822;
 name="nsmailIS.TMP"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="nsmailIS.TMP"

Message-ID: <3A929933.AA4F81@cs.strath.ac.uk>
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
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.lang.python
Subject: retrieving file data from an external server - where to start?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: k42.cs.strath.ac.uk
X-Original-NNTP-Posting-Host: k42.cs.strath.ac.uk
X-Trace: 20 Feb 2001 16:20:05 GMT, k42.cs.strath.ac.uk
Path: nntphost.cs.strath.ac.uk!k42.cs.strath.ac.uk
Xref: nntphost.cs.strath.ac.uk comp.lang.python:52930

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


--------------0CB8D9E42B1C70A4F8BE2724--