If Something Goes Wrong

A REST web service is expected to flag error conditions using HTTP status codes, in conjunction with error documents that describe the problem. As you might expect, XML-RPC does a similar thing in a more structured way. If an XML-RPC server can't complete a request for any reason, it will return a response containing a fault, instead of one containing a return value in params. A sample fault response is as follows < xml version 1.0 > < methodResponse> < fault> < value> <...

Passing Parameters from Python to C

After you have everything built and installed, importing your new extension module and invoking its one function is easy If you tried to pass in any arguments to your function, the interpreter will rightfully complain If you tried to pass in any arguments to your function, the interpreter will rightfully complain Because you'll most likely want to define functions that do accept arguments, you can use one of the other signatures for your C functions. For example, a normal function (one that...

The cgi Module Parsing HTML Forms

When you click one of the Submit buttons on SimpleHTMLForm.html, notice that you're not exactly GETting the resource cgi-bin PrintFormSubmission.cgi, the resource specified in the action attribute of the < FORM> tag. You're GETting a slightly different resource, something with the long, unwieldy identifier of 2& button Submit. This is how a GET form submission works The web browser gathers the values of the fields in the form you submitted and encodes them so they don't contain any...

MIME Multipart Messages

This isn't quite the e-mail message described earlier. That message was a short piece of text (Here's that picture I took of you.) and an attached image. This message is just the image. There's no space for the text portion in the body of the message putting it there would compromise the image file. The Content-Type header of a mail message can be text plain or image jpeg it can't be both. So how do mail clients create messages with attachments In addition to...

The LAME Project

LAME is (or was) an acronym that originally stood for LAME Ain't an MP3 Encoder. Whether it's officially considered an MP3 encoder or not isn't important to you, because it functions as a (most excellent) free and open-source library that is capable of encoding MP3s. Dozens of software projects use LAME but not many are implemented in Python, which is why you'll be using it as an example to demonstrate just how easy it is to create extension modules for Python that leverage an existing C code...