Next a library function is used to create (Web hosting packages)

Next a library function is used to create an opener object, which is then used to open the communication channel: opener = urllib2.build_opener() message = opener.open(request) When opening the channel, the opener has passed the request to the server, and the message object contains the response headers and a pointer to the body of any data. The headers are checked to determine whether the Content-Encoding header has a value of gzip , and if it is an appropriate message is sent to the console: if message.headers.get( Content-encoding ) == gzip : print ZIPPED! The zipped content is then read from the message into a buffer, which is then used to construct a file-like object on which the compression classes can operate. There are limits to the kinds of objects the compression code can work on, which is why the StringIO class is needed. It s not very elegant, but it works. A GzipFile object is created, and the fileObject reads through it, as you can see in the following lines: zipped = message.read() fileObject = StringIO.StringIO(zipped) data = gzip.GzipFile(fileobj=fileObject).read() The data that is read from the GzipFile object is decompressed back into its original form. However we are still in a block that runs only if the content encoding header says the data is zipped. If it isn t, the data can be read directly from the source. Finally the decompressed or as-delivered data is then printed to the console: else: data = message.read() print data The Trade Off In most circumstances the benefits of delivering or receiving compressed feed data far outweigh the costs. However, you should keep in mind that there are costs, not only for the additional code complexity but also for the processing required. For limited devices such as mobile phones it may make sense to avoid the computational load and always collect the uncompressed version of feeds. Client Producer: Blogging APIs The Client Producer part of a syndication system is the part the user employs to create the raw material for syndication. In other words, it s the authoring tool. Usually these are quite separate from the parts of the system that do the actual feed syndication. What the Client Producer produces is the content and metadata that corresponds to a weblog post, or perhaps to modify or delete an existing post. The data from the client is often sent back to the server and stored in a database, and only later is it converted into the RSS or Atom format. The fact that the authoring part of a system may be a separate component doesn t change the fact that the data it is dealing with is usually exactly the same kind of content and metadata that is published in 230 Chapter 19
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Leave a Reply