CGI Programming with Python Gouichi Iisaka The Company

  • Slides: 10
Download presentation
CGI Programming with Python Gouichi Iisaka The Company was called Cray Research Japan Co.

CGI Programming with Python Gouichi Iisaka The Company was called Cray Research Japan Co. , Ltd.

CGIのためのモジュール http: //www. python. org/download/Contributed. html#netweb z. JPython: Javaプラットホームで動作 z. SSL Extension http: //www.

CGIのためのモジュール http: //www. python. org/download/Contributed. html#netweb z. JPython: Javaプラットホームで動作 z. SSL Extension http: //www. as. cmu. edu/~geek/python-ssl. html zmod_pyapache http: //www. msg. com. mx/pyapache/

Jpythonサンプルコード from java import awt, applet class Button. Demo(applet. Applet): def init(self): self. b

Jpythonサンプルコード from java import awt, applet class Button. Demo(applet. Applet): def init(self): self. b 1 = awt. Button('Disable middle button', action. Performed=self. disable) self. b 2 = awt. Button('Middle button') self. b 3 = awt. Button('Enable middle button', enabled=0, action. Performed=self. enable) self. add(self. b 1) self. add(self. b 2) self. add(self. b 3) def enable(self, event): self. b 1. enabled = self. b 2. enabled = 1 self. b 3. enabled = 0 def disable(self, event): self. b 1. enabled = self. b 2. enabled = 0 self. b 3. enabled = 1

Jpythonサンプルコード from java import awt, applet class Checkbox. Demo(applet. Applet): def init(self): cb 1

Jpythonサンプルコード from java import awt, applet class Checkbox. Demo(applet. Applet): def init(self): cb 1 = awt. Checkbox('Checkbox 1') cb 2 = awt. Checkbox('Checkbox 2') cb 3 = awt. Checkbox('Checkbox 3', state=1) p 1 = awt. Panel(layout=awt. Flow. Layout()) p 1. add(cb 1) p 1. add(cb 2) p 1. add(cb 3) cbg = awt. Checkbox. Group() cb 4 = awt. Checkbox('Checkbox 4', cbg, 0) cb 5 = awt. Checkbox('Checkbox 5', cbg, 0) cb 6 = awt. Checkbox('Checkbox 6', cbg, 0) p 2 = awt. Panel(layout=awt. Flow. Layout()) p 2. add(cb 4) p 2. add(cb 5) p 2. add(cb 6) self. set. Layout(awt. Grid. Layout(0, 2)) self. add(p 1) self. add(p 2) self. validate()

CGIモジュール form = cgi. Field. Storage() form_ok = 0 if form. has_key("name") and form.

CGIモジュール form = cgi. Field. Storage() form_ok = 0 if form. has_key("name") and form. has_key("addr"): if form["name"]. value != "" and form["addr"]. value != "": form_ok = 1 if not form_ok: print "<H 1>Error</H 1>" print "Please fill in the name and addr fields. ” return …他の手続き. . .

CGIのデバッグ import sys import traceback print ”Content-type: text/html” print sys. stderr = sys. stdout

CGIのデバッグ import sys import traceback print ”Content-type: text/html” print sys. stderr = sys. stdout try: … デバッグしたいコード… except: print ”<PRE>” traceback. print_exc()