Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: src/Tools/faqwiz" os.chdir(FAQDIR) os sys.path.insert(0, SRCDIR) import faqwiz faqwiz except SystemExit, n: except SystemExit sys.exit(n) except: t, v, tb = sys.exc_type, sys.exc_value, sys.exc_traceback print print import cgi cgi cgi.print_exception(t, v, tb) .print_exception(t, tb CS 206 G. Dudek 150 - main code class FaqWizard: class FaqWizard def go(self): print 'Content-type: text/html' def __init__(self): req = self.ui.req or 'home' self. req or self.ui = UserInput() ui UserInput mname = 'do_%s' % req 'do_%s' req self.dir = FaqDir() FaqDir try: try: meth = getattr(self, mname) getattr(self, mname def do_home(self): self.prologue(T_HOME) emit(HOME) except AttributeError: AttributeError self.error("Bad request type %s." % `req`) else: try: def do_search(self): ... def do_index(self): ... def do_roulette(self): ... def do_show(self): ... def do_edit(self): ... def do_review(self): ... def do_help(self): ... ...etc... meth() meth except InvalidFile, exc: InvalidFile exc self.error("Invalid entry file name %s" % exc.file) exc except NoSuchFile, exc: NoSuchFile exc self.error("No entry with file name %s" % exc.file) exc except NoSuchSection, exc: NoSuchSection exc CS 206 G. Dudek self.error("No section number %s" % exc.section) exc self.epilogue() 151 Example: do_roulette() def do_roulette(self): import random files = self.dir.list() if not files: self.error("No entries.") return file = random.choice(files) self.prologue(T_ROULETTE) emit(ROULETTE) CS 206 G. Dudek 152 Persistence • All data stored in files (faqNN.MMM.htp) • Backed up by RCS files (RCS/faqNN.MMM.htp,v) – RCS logs and diffs viewable RCS viewable • RCS...
View Full Document

This note was uploaded on 04/02/2013 for the course MATH 222 taught by Professor Karlpeterrussell during the Spring '08 term at McGill.

Ask a homework question - tutors are online