Welcome to the "Web services for the Python developer" column. But wait, don't hesitate when we say "for Python developers." This column is not purely for the Python Guru, or even the Python journeyman. As much as possible, we will try to accommodate beginners and those who are merely curious.
We intend to direct our readers to high-quality resources for the relevant background information necessary for each topic in this series. It is our hope, that in this way Python developers of all levels will be able to gain something from this column. In many cases, however, Python's legendary readability (it has sometimes been called executable pseudocode) means that most readers will be able to follow the code with little trouble.
And there will be much code. This column will be hands-on and very practical. In most installments we shall actually be developing a useful Web Service, which you should be able to employ with little effort for your own purposes. So get out your snake-charming pipes and get ready to construct Web services more productively than you might have imagined. In this inaugural article, we shall explore the many features and resources that make Python such a great programming language for developing Web services.
A Bit of Background
Since you're in the Web services zone, there's a decent chance you know what a Web Service is -- if not, see the links in the Resources section for some good reading on the general topic. But in order to place Python within the world of Web services, we ask that you indulge us while we step back and build a little perspective.
The Web has developed at a remarkable pace since it's birth barely a decade ago. First came the original collection of interconnected articles and links. Then came CGI and with it the first glimpse of the Web's potential to revolutionize software development: CGI provided narrow, highly-specialized functions for presenting dynamic content. From these roots have come Web services.
One way to think about what sets Web services apart from other dynamic Web content is to think of application objects versus components. Objects are highly specialized bundles of code and data that are designed to drop into a sharply defined slot in an application. Components are also objects, but they are usually more generally applicable and highly reusable in a variety of applications and environments. Normally, they are associated with formal protocols (for example, CORBA, DCOM, and EJB) for communicating with other code, describing their interface to other code, and discovering and managing them at run time.
Similarly, Web services are, at the most basic level, simply a subclass of dynamic Web content, differentiated by their generality, reusability, and the formal protocols (SOAP, UDDI, WebDAV) that standardize their communication, interface definition, management, and so on.
So Where Does Python Come In?
Python has always had extensive support for basic Internet protocols, which along with its readability and ease of maintenance has made it a strong foundation for dynamic programming. Here we list some of the core facilities of Python that are useful for Web services development. Everything listed comes with Python and requires no additional download or installation.
With this panoply of facilities, Python has the basics of Web services well covered. However, we have mentioned the higher-level considerations that make Web services special. These features are generally the preserve of third-party additions and applications for Python.
A Brief Survey of Third-Party Python Tools
Beyond the "batteries included" approach in the Python standard library, there is a rich vein of third-party add-ons for Web service development (and almost any other purpose you can dream up). See the Resources section for links to sites that will assist you in locating tools for use with Python. All software discussed here is open source.
XML is a very popular data format for Web service purposes. Its high structure and extensibility, broad support, and variety of related standards make it popular for encoding requests, responses, and communications between sub-components of the service. We have already touched on Python's built-in XML facilities. There are also many third-party XML tools. The Python XML SIG develops the PyXML package which adds a variety of parsers, DOM and SAX tools, data-marshalling tools for WDDX and XML-RPC, and miscellaneous XML processing tools. There is also Sean McGrath's Pyxie for an original approach to XML processing.
An additional array of XML tools is provided in 4Suite (co-developed by the authors), which builds on PyXML and adds many XML-related facilities including DOM (transient and persistent), XPath, XPointer, XSLT, XLink, RDF, and XInclude. With these facilities alone, many aspects of a Web service can be developed with little custom code required. In particular, RDF is the most promising technology for describing relationships and data that must be indexed for Web services. Python has RDF support both in 4Suite and in James Tauber's Redfoot framework.
SOAP is certainly the darling protocol of Web services. SOAP is a protocol for sending messages to remote systems using strictly-specified XML embedded in HTML, SMTP, or other lower-level protocols. Pythonware's soaplib provides basic SOAP and XML-RPC support for Python. There are currently some interoperability problems between soaplib and other popular SOAP implementations, but a new release is imminent that promises improved interoperability and broader SOAP support. There is also some rougher and older SOAP code available from Ken MacLeod's Scarab project.
Fourthought's 4Suite Server (also co-developed by the authors) is an XML data server based on 4Suite that provides out-of-the box support for storing, managing, transmitting, and processing XML. It supports communications using CORBA, HTTP, and very basic SOAP, and will soon add more protocols such as WebDAV and SMTP.
Digital Creations develops Zope, a popular Python-based application server; Zope provides general object services, template-based HTML output, and WebDAV. XML support is in development.
Chuck Esterbrook's Webware is a suite of tools for developing Web-based applications in Python. It is similar to Java servlets, JSP, and similar facilities.
Finally, since most users still access the Web using HTML-only Web browsers, being able to render HTML is an important part of most Web services. DOM has some facilities for building HTML documents and 4Suite can output HTML from DOM or XSLT. If a template-based approach is preferred there is Robin Friedrich's very mature HTMLgen module.
Here are brief definitions for some of the jargon used in the article.
Common Object Request Broker Architecture (CORBA): The Object Management Group's standard for object-oriented components.
Distributed Component Object Model (DCOM): Microsoft's standard for object-oriented components.
Enterprise JavaBeans (EJB): A standard for Java-based component development.
Simple Object Access protocol (SOAP): A specification for encoding messages to remote objects in XML using protocols such as HTTP and SMTP.
Universal Description, Discovery and Integration (UDDI): A standard for directories of Web-based services.
Web Document Authoring and Versioning (WebDAV): A standard for modifying and managing documents on remote Web servers.
Document Object Model (DOM): A standard for object-oriented access to XML and HTML documents.
Simple API for XML (SAX): A specification for accessing XML documents using an event-based model.
Secure Sockets Layer (SSL): A standard for encrypted communication over the Internet and similar networks
Web Distributed Data Exchange (WDDX): A schema for exchanging program data as highly structured XML.
blog comments powered by Disqus