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
   284   285   286   287   288   289   290   291   292   293   294