�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!cgi1.pyo000064400000000427152531503600006123 0ustar00ó Afc@sdZdGHHdGHdGHdS(s CGI test 1 - check server setup.sContent-type: text/htmls

Hello world

s

This is cgi1.pyN(t__doc__(((s%/usr/lib64/python2.7/Demo/cgi/cgi1.pytswiki.pyo000064400000012401152531503600006236 0ustar00ó ¿œ^c@skdZddlZddlZddlZddlZddlZejZd„Zddd„ƒYZdS(s0Wiki main program. Imported and run by cgi3.py.iÿÿÿÿNcCsotjƒ}dGHH|jddƒ}|jddƒ}t|ƒ}t|d|dƒp^|j}||ƒdS(NsContent-type: text/htmltcmdtviewtpaget FrontPagetcmd_(tcgit FieldStoragetgetvaluetWikiPagetgetattrtNonetcmd_view(tformRRtwikitmethod((s%/usr/lib64/python2.7/Demo/cgi/wiki.pytmains  RcBsŸeZejƒZejjej dƒZ d„Z d„Z d„Z dd„Zd„Zd„Zd„Zd „Zdd „Zd „Zd „Zd „ZRS(icCs2|j|ƒstd‚n||_|jƒdS(Nspage name is not a wiki word(t iswikiwordt ValueErrortnametload(tselfR((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyt__init__s  cCs¦dGt|j|jƒƒGdGHdGHx?|jjƒD].}|jƒ}|sTdGHq4|j|ƒGHq4WdGHdG|jd|jdƒdGH|jdd d ƒd GHdS( Ns

s

s

s


teditsEdit this paget;RRsgo to front paget.(tescapet splitwikiwordRtdatat splitlinestrstript formatlinetmklink(RR tline((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR s cCs§g}x‘tjd|ƒD]}}|j|ƒr}tjj|j|ƒƒra|jd||ƒ}q‰|jd||dƒ}n t|ƒ}|j |ƒqWdj |ƒS(Ns(\W+)Rtnewt*t( tretsplitRtostpathtisfiletmkfileRRtappendtjoin(RR twordstword((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR(s tChangecCsZdG|G|jGdGHd|jGHd}||jGHdGHd|jGHdGHd|GHd GHdS( Ns

s

s
s7s/s,s
s%s
(Rt scripturlR(RR tlabelts((s%/usr/lib64/python2.7/Demo/cgi/wiki.pytcmd_edit5s    cCs—|jddƒjƒ|_|jƒ}|rIdGHdGHdGt|ƒGHnJdGHd}||jd|jGHdGHd GHd G|jd |j|jƒGHdS( NttextR#s%

I'm sorry. That didn't work

s8

An error occurred while attempting to write the file:s

ss/s?cmd=view&page=s

OK

s)

If nothing happens, please click here:R(RtstripRtstoreRR/RR(RR terrorR1((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyt cmd_create@s cCs|j|ddƒdS(NR0tCreate(R2(RR ((s%/usr/lib64/python2.7/Demo/cgi/wiki.pytcmd_newQscCstjd|ƒS(Ns[A-Z][a-z]+([A-Z][a-z]*)+(R$tmatch(RR-((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRTscCsSg}x=|D]5}|r5|jƒr5|jdƒn|j|ƒq Wdj|ƒS(Nt R#(tisupperR*R+(RR-tcharstc((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRWs  cCs2|dkr|j}ntjj|j|dƒS(Ns.txt(R RR&R'R+thomedir(RR((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR)_s  cCs'|jd|d|}d||fS(Ns?cmd=s&page=s%s(R/(RRRR3tlink((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRdscCsYy2t|jƒƒ}|jƒjƒ}|jƒWntk rKd}nX||_dS(NR#(topenR)treadR4tclosetIOErrorR(RtfR((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRhs  cCsˆ|j}yZt|jƒdƒ}|j|ƒ|rT|jdƒ rT|jdƒn|jƒdSWntk rƒ}dt|ƒSXdS(Ntws R#s IOError: %s(RRAR)twritetendswithRCRDtstr(RRREterr((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR5qs   N(t__name__t __module__ttempfilet gettempdirR?R&R'tbasenametsystargvR/RR RR2R7R9RRR R)RRR5(((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRs         (( t__doc__R&R$RRPRMRRR(((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyts<  README000064400000000665152531503600005433 0ustar00CGI Examples ------------ Here are some example CGI programs. For a larger example, see ../../Tools/faqwiz/. cgi0.sh -- A shell script to test your server is configured for CGI cgi1.py -- A Python script to test your server is configured for CGI cgi2.py -- A Python script showing how to parse a form cgi3.py -- A Python script for driving an arbitrary CGI application wiki.py -- Sample CGI application: a minimal Wiki implementation wiki.py000064400000007705152531503600006072 0ustar00"""Wiki main program. Imported and run by cgi3.py.""" import os, re, cgi, sys, tempfile escape = cgi.escape def main(): form = cgi.FieldStorage() print "Content-type: text/html" print cmd = form.getvalue("cmd", "view") page = form.getvalue("page", "FrontPage") wiki = WikiPage(page) method = getattr(wiki, 'cmd_' + cmd, None) or wiki.cmd_view method(form) class WikiPage: homedir = tempfile.gettempdir() scripturl = os.path.basename(sys.argv[0]) def __init__(self, name): if not self.iswikiword(name): raise ValueError, "page name is not a wiki word" self.name = name self.load() def cmd_view(self, form): print "

", escape(self.splitwikiword(self.name)), "

" print "

" for line in self.data.splitlines(): line = line.rstrip() if not line: print "

" else: print self.formatline(line) print "


" print "

", self.mklink("edit", self.name, "Edit this page") + ";" print self.mklink("view", "FrontPage", "go to front page") + "." def formatline(self, line): words = [] for word in re.split('(\W+)', line): if self.iswikiword(word): if os.path.isfile(self.mkfile(word)): word = self.mklink("view", word, word) else: word = self.mklink("new", word, word + "*") else: word = escape(word) words.append(word) return "".join(words) def cmd_edit(self, form, label="Change"): print "

", label, self.name, "

" print '
' % self.scripturl s = '' print s % self.data print '' print '' % self.name print '
' print '' % label print "
" def cmd_create(self, form): self.data = form.getvalue("text", "").strip() error = self.store() if error: print "

I'm sorry. That didn't work

" print "

An error occurred while attempting to write the file:" print "

", escape(error) else: # Use a redirect directive, to avoid "reload page" problems print "" s = '' print s % (self.scripturl + "?cmd=view&page=" + self.name) print "" print "

OK

" print "

If nothing happens, please click here:", print self.mklink("view", self.name, self.name) def cmd_new(self, form): self.cmd_edit(form, label="Create") def iswikiword(self, word): return re.match("[A-Z][a-z]+([A-Z][a-z]*)+", word) def splitwikiword(self, word): chars = [] for c in word: if chars and c.isupper(): chars.append(' ') chars.append(c) return "".join(chars) def mkfile(self, name=None): if name is None: name = self.name return os.path.join(self.homedir, name + ".txt") def mklink(self, cmd, page, text): link = self.scripturl + "?cmd=" + cmd + "&page=" + page return '%s' % (link, text) def load(self): try: f = open(self.mkfile()) data = f.read().strip() f.close() except IOError: data = "" self.data = data def store(self): data = self.data try: f = open(self.mkfile(), "w") f.write(data) if data and not data.endswith('\n'): f.write('\n') f.close() return "" except IOError, err: return "IOError: %s" % str(err) cgi1.pyc000064400000000427152531503600006107 0ustar00ó Afc@sdZdGHHdGHdGHdS(s CGI test 1 - check server setup.sContent-type: text/htmls

Hello world

s

This is cgi1.pyN(t__doc__(((s%/usr/lib64/python2.7/Demo/cgi/cgi1.pytscgi3.py000075500000000227152531503600005747 0ustar00#! /usr/bin/python2.7 """CGI test 3 (persistent data).""" import cgitb; cgitb.enable() from wiki import main if __name__ == "__main__": main() cgi3.pyo000064400000000506152531503600006123 0ustar00ó Afc@sFdZddlZejƒddlmZedkrBeƒndS(sCGI test 3 (persistent data).iÿÿÿÿN(tmaint__main__(t__doc__tcgitbtenabletwikiRt__name__(((s%/usr/lib64/python2.7/Demo/cgi/cgi3.pyts   cgi0.sh000075500000000232152531503600005722 0ustar00#! /bin/sh # If you can't get this to work, your web server isn't set up right echo Content-type: text/plain echo echo Hello world echo This is cgi0.sh cgi2.pyo000064400000001331152531503600006117 0ustar00ó Afc@sKdZddlZejƒddlZd„ZedkrGeƒndS(s%CGI test 2 - basic use of cgi module.iÿÿÿÿNcCsptjƒ}dGHH|s dGHnLdGHxD|jƒD]6}||j}dGtj|ƒGdGtj|ƒGHq2WdS(NsContent-type: text/htmls

No Form Keys

s

Form Keys

s

t:(tcgit FieldStoragetkeystvaluetescape(tformtkeyR((s%/usr/lib64/python2.7/Demo/cgi/cgi2.pytmain s  t__main__(t__doc__tcgitbtenableRRt__name__(((s%/usr/lib64/python2.7/Demo/cgi/cgi2.pyts    cgi2.pyc000064400000001331152531503600006103 0ustar00ó Afc@sKdZddlZejƒddlZd„ZedkrGeƒndS(s%CGI test 2 - basic use of cgi module.iÿÿÿÿNcCsptjƒ}dGHH|s dGHnLdGHxD|jƒD]6}||j}dGtj|ƒGdGtj|ƒGHq2WdS(NsContent-type: text/htmls

No Form Keys

s

Form Keys

s

t:(tcgit FieldStoragetkeystvaluetescape(tformtkeyR((s%/usr/lib64/python2.7/Demo/cgi/cgi2.pytmain s  t__main__(t__doc__tcgitbtenableRRt__name__(((s%/usr/lib64/python2.7/Demo/cgi/cgi2.pyts    wiki.pyc000064400000012401152531503600006222 0ustar00ó ¿œ^c@skdZddlZddlZddlZddlZddlZejZd„Zddd„ƒYZdS(s0Wiki main program. Imported and run by cgi3.py.iÿÿÿÿNcCsotjƒ}dGHH|jddƒ}|jddƒ}t|ƒ}t|d|dƒp^|j}||ƒdS(NsContent-type: text/htmltcmdtviewtpaget FrontPagetcmd_(tcgit FieldStoragetgetvaluetWikiPagetgetattrtNonetcmd_view(tformRRtwikitmethod((s%/usr/lib64/python2.7/Demo/cgi/wiki.pytmains  RcBsŸeZejƒZejjej dƒZ d„Z d„Z d„Z dd„Zd„Zd„Zd„Zd „Zdd „Zd „Zd „Zd „ZRS(icCs2|j|ƒstd‚n||_|jƒdS(Nspage name is not a wiki word(t iswikiwordt ValueErrortnametload(tselfR((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyt__init__s  cCs¦dGt|j|jƒƒGdGHdGHx?|jjƒD].}|jƒ}|sTdGHq4|j|ƒGHq4WdGHdG|jd|jdƒdGH|jdd d ƒd GHdS( Ns

s

s

s


teditsEdit this paget;RRsgo to front paget.(tescapet splitwikiwordRtdatat splitlinestrstript formatlinetmklink(RR tline((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR s cCs§g}x‘tjd|ƒD]}}|j|ƒr}tjj|j|ƒƒra|jd||ƒ}q‰|jd||dƒ}n t|ƒ}|j |ƒqWdj |ƒS(Ns(\W+)Rtnewt*t( tretsplitRtostpathtisfiletmkfileRRtappendtjoin(RR twordstword((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR(s tChangecCsZdG|G|jGdGHd|jGHd}||jGHdGHd|jGHdGHd|GHd GHdS( Ns

s

s
s7s/s,s
s%s
(Rt scripturlR(RR tlabelts((s%/usr/lib64/python2.7/Demo/cgi/wiki.pytcmd_edit5s    cCs—|jddƒjƒ|_|jƒ}|rIdGHdGHdGt|ƒGHnJdGHd}||jd|jGHdGHd GHd G|jd |j|jƒGHdS( NttextR#s%

I'm sorry. That didn't work

s8

An error occurred while attempting to write the file:s

ss/s?cmd=view&page=s

OK

s)

If nothing happens, please click here:R(RtstripRtstoreRR/RR(RR terrorR1((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyt cmd_create@s cCs|j|ddƒdS(NR0tCreate(R2(RR ((s%/usr/lib64/python2.7/Demo/cgi/wiki.pytcmd_newQscCstjd|ƒS(Ns[A-Z][a-z]+([A-Z][a-z]*)+(R$tmatch(RR-((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRTscCsSg}x=|D]5}|r5|jƒr5|jdƒn|j|ƒq Wdj|ƒS(Nt R#(tisupperR*R+(RR-tcharstc((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRWs  cCs2|dkr|j}ntjj|j|dƒS(Ns.txt(R RR&R'R+thomedir(RR((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR)_s  cCs'|jd|d|}d||fS(Ns?cmd=s&page=s%s(R/(RRRR3tlink((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRdscCsYy2t|jƒƒ}|jƒjƒ}|jƒWntk rKd}nX||_dS(NR#(topenR)treadR4tclosetIOErrorR(RtfR((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRhs  cCsˆ|j}yZt|jƒdƒ}|j|ƒ|rT|jdƒ rT|jdƒn|jƒdSWntk rƒ}dt|ƒSXdS(Ntws R#s IOError: %s(RRAR)twritetendswithRCRDtstr(RRREterr((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyR5qs   N(t__name__t __module__ttempfilet gettempdirR?R&R'tbasenametsystargvR/RR RR2R7R9RRR R)RRR5(((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyRs         (( t__doc__R&R$RRPRMRRR(((s%/usr/lib64/python2.7/Demo/cgi/wiki.pyts<  cgi1.py000075500000000620152531503600005742 0ustar00#! /usr/bin/python2.7 """CGI test 1 - check server setup.""" # Until you get this to work, your web server isn't set up right or # your Python isn't set up right. # If cgi0.sh works but cgi1.py doesn't, check the #! line and the file # permissions. The docs for the cgi.py module have debugging tips. print "Content-type: text/html" print print "

Hello world

" print "

This is cgi1.py" cgi3.pyc000064400000000506152531503600006107 0ustar00ó Afc@sFdZddlZejƒddlmZedkrBeƒndS(sCGI test 3 (persistent data).iÿÿÿÿN(tmaint__main__(t__doc__tcgitbtenabletwikiRt__name__(((s%/usr/lib64/python2.7/Demo/cgi/cgi3.pyts   cgi2.py000075500000000726152531503600005752 0ustar00#! /usr/bin/python2.7 """CGI test 2 - basic use of cgi module.""" import cgitb; cgitb.enable() import cgi def main(): form = cgi.FieldStorage() print "Content-type: text/html" print if not form: print "

No Form Keys

" else: print "

Form Keys

" for key in form.keys(): value = form[key].value print "

", cgi.escape(key), ":", cgi.escape(value) if __name__ == "__main__": main()