[Zope] URL Substitution.

Alexandre A. Rodioukov simuran@home.com
10 Feb 2000 23:58:53 -0700


Ok, I'm posting followup to my one posting :) What I did, I finally
decided to write external method. Here follows the code:

[ http_fetch.py ]
def fetch_file(uri):
        from httplib import HTTP
        from urlparse import urlparse

        parsed_uri=urlparse(uri)

        h = HTTP(parsed_uri[1])
        h.putrequest('GET', parsed_uri[2])
        h.putheader('Accept', 'text/html')
        h.putheader('Accept', 'text/plain')
        h.endheaders()
        errcode, errmsg, headers = h.getreply()
        if errcode == 200:
                f = h.getfile()
                return f.read()
[EOF]
While calling you need to pass argument(uri) taht points to document
you want to fetch.

Works fine for me :) Hope that would be useful. Comments and
suggestions are always very welcome to simuran@home.com

With best regards, 
Alexandre.