Interfacing with COM: Cheap Public Relations

We use the data to do two things. First, we’ll write a program that’s run periodically (say, at 2 a.m., every night[69]) and looks through the saved data, finds out which saved pickled files correspond to complaints, and prints out a customized letter to the complainant. Sounds sophisticated, but you’ll be surprised at how simple it is using the right tools. Joe’s web site is on a Windows machine, so we’ll assume that for this program, but other platforms work in similar ways.

Before we talk about how to write this program, a word about the technology it uses, namely Microsoft’s Common Object Model (COM). COM is a standard for interaction between programs (an Object Request Broker service, to be technical), which allows any COM-compliant program to talk to, access the data in, and execute commands in other COM-compliant programs. Grossly, the program doing the calling is called a COM client, and the program doing the executing is called a COM server. Now, as one might suspect given the origin of COM, all major Microsoft products are COM-aware, and most can act as servers. Microsoft Word Version 8 is one of those, and the one we’ll use here. Indeed, Microsoft Word is just fine for writing letters, which is what we’re doing. Luckily for us, Python can be made COM-aware as well, at least on Windows 95, Windows 98, and Windows NT. Mark Hammond and Greg Stein have made available a set of extensions to Python for Windows called win32com that ...

Get Learning Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.