Friday, March 15, 2002


I hope this works... I'm posting via email since I'm at work, and if this screws up my page, it'll be screwed up until I get home.

Just for giggles, I put together the Zope Python Script you see at the end of this post. I put it in the root of my Zope installation, and named it "as.opml".

It renders the current Zope level in opml in a way that will allow you to drill down into the Zope structure in a Radio outline.

Perhaps not the same as the World Outline, but interesting for the possibilities.

I used already existing Radio node types, so there should be nothing needed to install on the Radio side. You just need to drop the script into your Zope root.

To bootstrap the process, you need to save the output of "http://yourZopeRoot/as.opml" into a file (with the .opml extension) which you can then open up in Radio. Then you can traverse your Zope site to your heart's content.

Note -- it doesn't do any editing, nor does it display the contents of any Zope objects. That is left as an exercise for the reader.

Here's the code (I hope it formats correctly):

## Script (Python) "as.opml"
##bind container=container
##bind context=context
##bind namespace
##bind script=script
##bind subpath=traverse_subpath
##parameters
##title
##
print """<?xml version="1.0"?>"""
print """<opml version="1.0">"""
print """<head>"""
print """<title>%s</title>""" % context.title
print """</head><body>"""
folderContents = context.objectItems()
if len(folderContents):
    for x in folderContents:
        if x[1].meta_type == "Folder":
            print """<outline text="%s" type="file"url="%s/as.opml"/>""" 
                % (x[0], x[1].absolute_url())
        else:
            print """<outline text="%s" type="Zope %s"/>""" 
                % (x[0], x[1].meta_type)
else:
    print """<outline text="empty"/>"""
print "</body></opml>"

context.REQUEST['RESPONSE'].setHeader("Content-Type", "text/xml")
return printed


1:54:06 PM    comments ()  trackback []