[Zope] Easily including external HTML file?

Alexander Staubo alex@mop.no
Thu, 17 Jun 1999 05:13:22 +0200


>-----Original Message-----
>From: michel@digicool.com [mailto:michel@digicool.com]
>Sent: 17. juni 1999 04:16
>To: Alexander Staubo
>Cc: Zope Mailing List (E-mail)
>Subject: Re: [Zope] Easily including external HTML file?
>
>
>Alexander Staubo <alex@mop.no> writes:
>
>> Afaik, Zope does not have any built-in document grabbing
>routines, but
>> it's real easy to do with httplib in an External Method.
>Something like:
>>
>> import httplib
>>
>> def GetLinuxToday():
>>   http = httplib.HTTP('linuxtoday.com')
>>   http.putrequest('GET', '/backend/lthead.inc')
>>   http.putheader('Accept', 'text/html')  # we can handle text/html
>>   http.putheader('Accept', 'text/plain')  # we can handle text/plain
>>   http.endheaders()
>>   httpcode, httpmsg, headers = http.getreply()  # get
>response headers
>>   if httpcode != 200:
>>     raise "Could not get document"  # HTTP error
>>   doc = http.getfile()
>>   data = doc.read()  # read file
>>   doc.close()
>>   return data
>>
>> Didn't test this inside Zope, but it works standalone. Just
>put it in a
>> file in Zope's extensions directory (eg., c:\zope\extensions), add an
>> External Method, enter GetLinuxToday as id and function
>name, and call
>> it up in a document:
>>
>> 	<!--#var "GetLinuxToday()"-->
>>
>
>Alternatively you could genericize this method in the obvious way
>(pass the URL into the method)

Thought I'd leave that as an exercise for the reader.

>I'll speak to Jim about the
>possibility of getting something like this into the DTML _ namespace
>now that 2.0 is concurrent (The problem with this in 1.x is, of
>course, the getreply() call blocking the Zope process, unless you're
>*positive* that a blocking call will return almost immediately, you
>shouldn't use one in 1.x).

Of course, as with anything else -- lord knows posting rows to an SQL
database can take time, too. :-)  Which is the reason I (and everybody
else, I guess) is looking hungrily towards Zope 2.0 and tearing my hair
out in frustration over its unfinished state. :-)

>PS My new mailer quotes properly!  Forget Outlook!

Your new mailer has calendar scheduling, contact management, hierchical
folder storage, scheduled offline archiving, custom folder views, and
support for Exchange Server? If so, I'll _gladly_ use it.

(Okay, I could do without the Exchange part. What a piece of feces.
Phewey!)

>PPS (XEmacs with Gnus/nnimap)

Emacs for mail. Now _that_ sounds fun.

>> Hope this helps.
>>
>> --
>> Alexander Staubo             http://www.mop.no/~alex/
>> "`Ford, you're turning into a penguin. Stop it.'"
>> --Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
>>
>> >-----Original Message-----
>> >From: dyork@mercury.mv.net [mailto:dyork@mercury.mv.net]On
>> >Behalf Of Dan
>> >York
>> >Sent: 17. juni 1999 02:46
>> >To: zope@zope.org
>> >Subject: [Zope] Easily including external HTML file?
>> >
>> >
>> >Greetings!  I've been lurking for a bit and have appreciated
>> >the tips and ideas I've picked up on the list.  But now I have
>> >a question.  In one of my pages, I would like to pull in the
>> >latest stories from Linux Today.  They explain what to do at:
>> >
>> >  http://linuxtoday.com/linkus.html
>> >
>> >All I would like to do is pull the following file into the
>> >middle of a DTML document:
>> >
>> >  http://linuxtoday.com/backend/lthead.inc
>> >
>> >Now I frequently did this before with Apache and server-side
>> >includes, but I can't figure out exactly how to do this using
>> >DTML.  In looking around zope.org, I found the contributed
>> >external method for pulling in items from Slashdot.org:
>> >
>> >  http://www.zope.org/Download/Contrib/slashdot.py
>> >
>> >And while that works... and I could sit and modify the python
>> >to have it go pull in the LinuxToday info... I just find myself
>> >sitting here thinking there's got to be a better way to do this!
>> >All I want to do is pull in the LT file... no formatting or
>> >anything else.
>> >
>> >Any ideas you have will be appreciated.
>> >
>> >Thanks,
>> >Dan
>> >--
>> >--------------------------------------------------------
>> >Dan York, Certification Program Manager, Linuxcare, Inc.
>> >dyork@linuxcare.com    http://www.linuxcare.com/
>> >415-740-4519 mobile, 603-268-0691 tel, 603-268-0103 fax
>> >Linuxcare.  At the center of Linux.
>> >--------------------------------------------------------
>> >
>> >_______________________________________________
>> >Zope maillist  -  Zope@zope.org
>> >http://www.zope.org/mailman/listinfo/zope
>> >
>> >(For developer-specific issues, use the companion list,
>> >zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>> >
>>
>>
>> _______________________________________________
>> Zope maillist  -  Zope@zope.org
>> http://www.zope.org/mailman/listinfo/zope
>>
>> (For developer-specific issues, use the companion list,
>> zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>