Page 289 -
P. 289
web development
Your Python Toolbox
You’ve got Chapter 7 under your
belt and you’ve added some key
Python techiques to your toolbox.
The Model-View-Controller pattern lets
you design and build a webapp in a CHAPTER 7
maintainable way.
The model stores your webapp’s data.
The view displays your webapp’s user
Python Lingo interface.
The controller glues everything together
with programmed logic.
• “@property” - a decorator that
lets you arrange for a class method to
The standard library string module
appear as if it is a class attribute.
includes a class called Template,
which supports simple string substitutions.
Web Lingo The standard library http.server
module can be used to build a simple web
server in Python.
• “webapp” - a program that runs on The standard library cgi module
the Web. provides support for writing CGI scripts.
• “web request” - sent from the web The standard library glob module is
browser to the web server. great for working with lists of filenames.
• “web response” - sent from the web Set the executable bit with the chmod
server to the web browser in repsonse
+x command on Linux and Mac OS X.
to a web request. The standard library cgitb module,
• “CGI” - the Common Gateway errors within your browser.
when enabled, lets you see CGI coding
Interface, which allows a web server to
run a server-side program.
Use cgitb.enable() to switch on
• “CGI script” - another name for a CGI tracking in your CGI code.
Use cgi.FieldStorage() to
server-side program. access data sent to a web server as part
of a web request; the data arrives as a
Python dictionary.
you are here 4 253