From f8f0fb70692c5fe5fc35099f8559413beaee7734 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 23 May 1997 21:21:43 +0000 Subject: [PATCH] Added last mtime on whole faq. Added more elaborate explanation of version conflict. Set fake header on commit so show() shows the new mtime. Reorder name/email fields to be after the log message. --- Tools/faqwiz/faqmain.py | 89 ++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/Tools/faqwiz/faqmain.py b/Tools/faqwiz/faqmain.py index 12eca59a4db..a8e85bc9f2a 100644 --- a/Tools/faqwiz/faqmain.py +++ b/Tools/faqwiz/faqmain.py @@ -8,32 +8,42 @@ XXX TO DO XXX User Features TO DO -- next/prev/index links in do_show? +- next/prev/index links in do_show??? - explanation of editing somewhere -- embellishments, GIFs, crosslinks, hints, etc. -- make references to other Q's and whole sections into links +- embellishments, GIFs, hints, etc. - support adding annotations, too +- restrict recent changes to last week (or make it an option) +- extended search capabilities XXX Management Features TO DO +- username/password for authors - create new sections - rearrange entries - delete entries +- freeze entries - send email on changes? - send email on ERRORS! - optional staging of entries until reviewed? -- freeze entries -- username/password for authors -- read section titles from a file (could be a Python file: import faqcustom) + (could be done using rcs branches!) +- prevent race conditions on nearly simultaneous commits + +XXX Performance + +- could cache generated HTML +- could speed up searches with a separate index file XXX Code organization TO DO +- read section titles from a file (could be a Python file: import faqcustom) - customize rcs command pathnames (and everything else) - make it more generic (so you can create your own FAQ) - more OO structure, e.g. add a class representing one FAQ entry """ +# NB for timing purposes, the imports are at the end of this file + NAMEPAT = "faq??.???.htp" NAMEREG = "^faq\([0-9][0-9]\)\.\([0-9][0-9][0-9]\)\.htp$" @@ -160,11 +170,24 @@ class FAQServer: self.show(name, headers['title'], text) def do_all(self): + import fnmatch, stat self.prologue("The Whole Python FAQ") - print "
" names = os.listdir(os.curdir) + lastmtime = 0 + for name in names: + if not fnmatch.fnmatch(name, NAMEPAT): + continue + try: + st = os.stat(name) + except os.error: + continue + lastmtime = max(lastmtime, st[stat.ST_MTIME]) + if lastmtime: + print time.strftime("Last changed on %c %Z", + time.localtime(lastmtime)) names.sort() section = None + print "
" for name in names: headers, text = self.read(name) if headers: @@ -419,10 +442,23 @@ class FAQServer: version = self.version curversion = self.getversion(name) if version != curversion: - self.error("Version conflict.", - "You edited version %s but current version is %s." % ( - version, curversion), - 'Reload.' % name) + self.error( + "Version conflict.", + "You edited version %s but current version is %s." % ( + version, curversion), + """ +

+ The two most common causes of this problem are: +

+

+ """, + 'Click here to reload the entry and try again.') return text = self.text title = self.title @@ -494,6 +530,16 @@ class FAQServer: f.write(log) f.write("\n") f.close() + + # Do this for show() below + self.headers = { + 'title': title, + 'last-changed-date': now, + 'last-changed-author': author, + 'last-changed-email': email, + 'last-changed-remote-host': remhost, + 'last-changed-remote-address': remaddr, + } p = os.popen(""" /depot/gnu/plat/bin/rcs -l %s &1 @@ -514,8 +560,6 @@ class FAQServer: "Exit status 0x%04x" % sts) if output: print "

%s
" % cgi.escape(output) - print '
' - print 'Reload this entry.' % name def set_cookie(self, author, email): name = "Python-FAQ-ID" @@ -558,19 +602,19 @@ class FAQServer: email = email or e print """ Title:
- + + """ % (self.escape(title), cgi.escape(string.strip(text))) + print """ +
+ Log message (reason for the change):
+
Please provide the following information for logging purposes:
Name :
Email: -
- Log message (reason for the change):
- - """ % (self.escape(author), self.escape(email), self.escape(self.log)) + """ % (self.escape(self.log), self.escape(author), self.escape(email)) def escape(self, s): import regsub @@ -619,8 +663,6 @@ class FAQServer: return headers, text def show(self, name, title, text, edit=1): - # XXX Should put tags around recognizable URLs - # XXX Should also turn "see section N" into hyperlinks print "

%s

" % cgi.escape(title) pre = 0 for line in string.split(text, '\n'): @@ -765,7 +807,7 @@ class FAQServer: print "Content-type: text/html" dt = 0 -wanttime = 1 +wanttime = 0 try: import time t1 = time.time() @@ -774,6 +816,7 @@ try: x.main() t2 = time.time() dt = t2-t1 + wanttime = 1 except: print "\n
Sorry, an error occurred" cgi.print_exception()