#! /usr/bin/python from socket import * import sys import BaseHTTPServer import SocketServer import libxml2 import libxslt import re import urllib class myHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): def query(self,q): self.style = createStylesheet(q) self.doc = libxml2.parseFile( blogfile ) try: self.result = self.style.applyStylesheet(self.doc, None) except: self.cleanup() return "bad query: %s" % q strResult = self.style.saveResultToString(self.result) css = getCss() script = getScript() preamble = getPreamble(q) page = """ XPath query of Jon's Radio %s%s %s """ % (css, script, preamble, strResult) self.cleanup() return page def cleanup(self): try: self.doc.freeDoc() self.style.freeStylesheet() self.result.freeDoc() except: pass def do_GET(self): xhtml = self.send_head() self.wfile.write(xhtml) def send_head(self): q = self.requestline.split()[1] q = re.sub('^/\?','',q) q = urllib.unquote(q) xhtml = self.query(q) if ( len (xhtml) > maxchars ): xhtml = "query returned more than %d characters" % maxchars self.send_response(200) self.send_header("Content-type", "text/html") self.send_header("Content-Length", len(xhtml)) self.end_headers() return xhtml def getXsltTemplate(): return '''
Results:

Entries searched:

Date of oldest entry searched:

Date of newest entry searched:

http://weblog.infoworld.com/udell/.html# ()

Source:

''' def getPreamble(q): preamble = '''
choose xpath query from list, modify/reenter below all paragraphs containing phrase
''' preamble = preamble.replace('__QUERY__', q) option = '