RE: [Zope] Easily including external HTML file?
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()"--> 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 )
participants (1)
-
Alexander Staubo