Return to Home Page
      Blog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     FAQ      Search
 

4-26-03 RSS Feed up

This morning I got inspired to try to set up the RSS feed for this web log. After resurrecting my Zope knowledge and thrashing about a bit, I believe I have something that works, that you can see links to on all weblog pages (please let me know if it doesn't work for you; I'm new at RSS so it's likely that I got something wrong).

As usual, the Zope solution (once I figured it out) was simple and elegant. The static stuff was placed in a DTML document that looks like this:

<?xml version="1.0" ?>
<rss version="2.0">
<channel>
  <title>Thinking About Computing</title> 
  <link>http://www.MindView.net/WebLog/</link> 
  <description>Bruce Eckel's Web Log</description> 
  <language>en-us</language>
  <generator>MindView WeblogRSS.py v1.0</generator> 
  <copyright>Copyright 2003 MindView, Inc</copyright> 
  <dtml-var RSSbody>
</channel>
</rss>

The dynamically-generated part was created by the following Zope extension (called by RSSbody):

def RSSFile(self):
  list = []
  for f in self.objectValues(): # Could use a list comprehension to do this!
    if f.getId().startswith("log-"):
      list.append((f.getId(), f))
  list.sort()
  list.reverse()
  rss = ""
  for id, f in list[:8]: # Only use the most recent 8 entries
    rss = rss + "<item>\n"
    rss = rss + "<title>" + f.title.split(' ', 1)[1] + "</title>\n"
    rss = rss + "<pubDate>" + f.title.split(' ', 1)[0] + "</pubDate>\n"
    rss = rss + "<link>" + f.absolute_url() + "</link>\n"
    # Remove first and last lines:
    body = "\n".join(f.document_src().split("\n")[1:-1])
    body = body.replace('&', '&amp;')
    body = body.replace('<', '&lt;')
    body = body.replace('>', '&gt;')
    rss = rss + "<description>\n" + body + "\n</description>\n"
    rss = rss + "</item>\n"
  return rss
Since I don't program Zope extensions every day, it took some research (mostly of my own code) to remember how to do this. But every time I use Zope, I believe I'm much more productive than if I were to use any of the non-Python alternatives (I suppose that's what keeps all of us stuck in whatever technology we're stuck in -- the believe that we're more productive with that, and that changing would involve more effort and uncertainty than it would be worth).

The next step will be to create the system that will allow me to email the weblogs in (using the same approach as described in previous weblogs for maintaining the FAQ).

    Links I Read
Cafe Au Lait
Artima
Daily Python URL
Martin Fowler
Joel on Software
Paul Graham
Cringely
Search     Home     Web Log     Articles     Calendar     Books     CD-ROMS     Seminars     Services     Newsletter     About     Contact     Site Feedback     Site Design     Server Maintenance     Powered by Zope
©2003 MindView, Inc.