Download TEAM LinG - LinuxTone.Org

Transcript
Chapter 21
Summar y
Web applications are powerful and popular; with Python, they’re also easy to write. The REST architecture made the web usable and successful: Employing it when designing your application gives you a
head start. Web applications are designed for humans; a web service is just a web application designed
for use by software scripts instead. Expose REST and XML-RPC web services for simplicity and easy
adoption, SOAP for heavy-duty tasks or when interfacing with Java or .NET applications. Make use of
the web services provided by others: They’re opening up their data sets and algorithms for your benefit.
Exercises
1.
2.
538
What’s a RESTful way to change BittyWiki so that it supports hosting more than one Wiki?
Write a web application interface to WishListBargainFinder.py. (That is, a web application
that delegates to the Amazon Web Services.)
3.
The BittyWiki API makes the raw wiki markup of a page available when you GET a page (REST
interface) or call the getPage method (XML-RPC and SOAP interfaces). Suppose your web service users start wanting to get BittyWiki pages rendered as HTML fragments so that they don’t
have to write their own transformations from BittyWiki markup to HTML. What’s a RESTful
way to solve the problem? What’s a solution that’s more in keeping with the XML-RPC or
SOAP philosophies?
4.
The wiki search-and-replace spider looks up every new WikiWord it encounters to see whether
it corresponds to a page of the wiki. If it finds a page by that name, that page is processed.
Otherwise, nothing happens and the spider has wasted a web service request. How could the
web service API be changed so that the spider could avoid those extra web service requests for
nonexistent pages?
5.
Suppose that, to prevent vandalism, you change BittyWiki so that pages can’t be deleted.
Unfortunately, this breaks the wiki search-and-replace spider, which sometimes deletes a page
before recreating it with a new name. What’s a solution that meets both your needs and the
needs of the spider’s users?
TEAM LinG