An Introduction to CGI

CGI (Common Gateway Interface) is a standardized way for the Web Server to invoke an external program to handle the client request. It is possible for the external program to access databases, documents, and other programs as part of the request, as well, and present customized data to viewers via the Web. A CGI script can be written in any language, but here, of course, we are using only Python. CGI enables you to handle from the low end of mail-forms and counter programs to the most complex...

AOLserver Web Server

This is a Web Server created and used by AOL. Note that anyone using AOLserver would be better off learning TCL. For details, see The project that embeds Python in the AOLServer Web Server, is now semi-stable for simple CGI-style operations, and provides a 4-5x speedup over the straight CGI. Check it out at http pywx.sourceforge.net. Microsoft IIS and PWS You can set up both Microsoft IIS Server and Personal Web Server (PWS) to call the Python interpreter to handle Python CGI scripts.

Debugging and Testing Your Script

Before putting your CGI scripts online, you need to be sure that they are working fine. You have to test them carefully, especially in near bounds and out of bounds conditions. A script that crashes in the middle of its job can cause large problems, such as data inconsistency in a database application. This is why you would use a transaction when updating a database from a cgi script (if it was deemed important enough). You should eliminate most of the problems by running your script from the...

Python XML Package

For those who want to play around with XML in Python, there will be a Python XML package to serve several purposes at once. This package will contain everything required for basic XML applications, along with documentation and sample code basically, something easy to compile and install. A release candidate of the latest release of this package is now available as PyXML-0.5.5.tar.gz (GPG signature), dated June 5, 2000. This version contains SAX, the Pyexpat module, sgmlop, the prototype DOM...

Index terms contained in this section

Public attrs() attribute public methodsQ attribute readonly attrs() attribute applications Excel opening and manipulating from Python 2nd 3rd 4th 5th 6th transferring data between win32all opening and manipulating from Python 2nd 3rd 4th 5th 6th attributes public attrs() public methodsQ readonly attrs() AutoFitQ function calculator object source code 2nd 3rd 4th 5th 6th Cells() function changing Common Object Model (COM) creating clients, Excel 2nd 3rd importing calculator object 2nd 3rd 4th...

Summary

This chapter explains how to use Python to interface objects from different applications on a single machine, and across networks through distributed systems. Python has very comprehensive support for object interfacing and distributing technologies. COM is the most widely used component software model in the world when it comes to object interfacing. COM provides a rich set of integrated services, a wide choice of easy-to-use tools, and a large set of available applications. The COM genealogy...

Environment Variables

Environment variables are one of the methods that Web servers use to pass information to a CGI script. They are created and assigned appropriate values within the environment that the server produces for the CGI script. The next code generates a list of all environment variables that you have available at the moment, in your browser. import os print Content-type text html n print of Environment print lt BODY gt print s gt s lt BR gt k,v print The following list is the output collected from my...

Code Examples

This example generates a Python COM server that exposes a parking lot object. The example uses a Visual Basic graphical interface to manipulate the vehicles of this parking lot. Each vehicle is a Python Object that is also defined as a Python COM Server object. The first thing to do is to generate two clsids one for each object. gt gt gt import pythoncom gt gt gt print pythoncom.CreateGuid BD2CB7C0-3BB9-11D4-804E-00 50 041A5111 gt gt gt print pythoncom.CreateGuid BD2CB7C1-3BB9-11D4-804E-00 50...

ActiveX

An ActiveX control is an OLE control that can live inside an HTML page it can be simple Window objects, such as buttons, text boxes, or scrollbars. It also can be quite complicated, for example, a bar chart graph display can be an ActiveX control. An entire spreadsheet can also be a single control. Each ActiveX control has properties and reacts to external events. Its properties can be modified to change its appearance. For example, its containing program can set color and fonts. External...

Implementing COM Objects in Python

Script Form Edit Delphi

In order to implement COM objects in the Python version of Windows, you need a set of extensions developed by Mark Hammond and Greg Stein. Part of the win32com package, these extensions enable you to do everything that is COM-related, including writing COM clients and COM servers. The following link takes you to the download page of these extensions All the Win32 extensions including the COM extensions are part of the win32all installation package. This package also installs the PythonWin IDE...