Dr. Dobb's Journal - February 2009 - (Page 20) d02moore_p3cp 12/11/08 1:25 PM Page 20 Strategic Vision COMPUTING IN THE CLOUDS continued from page 18 One caveat to all this AWS fun: Only S3 and SimpleDB are persistent. If you deactivate a virtual machine or it fails, all of its memory (including allocated disk space) is also deactivated. Therefore, you must move critical information into the SimpleDB or S3. While you can get the latest pricing at the AWS site, here are some typical costs: • AWS $ Small machine $0.10/hour, $0.100 per GB in, $0.170 first 10TB out • S3 $ $0.15 GB/Month, $0.100 per GB In, $0.170 first 10TB out • SQS $: $0.01 by request, $0.100 per GB In, $0.170 first 10TB out • SimpleDB $: $0.100 per GB in, $0.170 first 10TB out and $1.50 GB/Month The costs appear nominal but can add up as you take advantage of the operations. For example, a small machine allocated for an entire month would cost over $72. This may exceed the cost from a typical ISP. The secret is in the elasticity. You probably don’t need the computer for every hour in a month. • Includes all of the APIs and libraries available on App Engine. • Provides a runtime environment built on Python (2.5) • Uses Django for templating and MVC architecture • When uploaded to a free account, an app can use up to 500MB of persistent storage and enough CPU and bandwidth for about 5 million page views a month. • Web apps run on Google’s infrastructure. • Apps may use a free domain name on Google’s appspot.com domain, or you can also use Google Apps to serve it from your own domain. • Apps can be intranetted. correspond to HTTP get and post handlers, which are associated with Web 2.0 URL reference style invocations via the two lines configuring, then running the application: application = webapp.WSGIApplication([('/', MainPage),('/todo', ToDo), ('/help, HelpPage) ('/markDone', MarkDone)],debug=True) wsgiref.handlers.CGIHandler(). run(application) An Example Application Architecturally, GAE uses a familiar modelview-controller application structure, with the model and controller code conveniently packaged into the same module. To illustrate, we’ve created a simple “To Do” List application called “goalpost.” You can see how it operates at goalposter.appspot.com. When you log in, you get a screen that resembles Figure 8. Typing in a text string (for example, “Finish Canoe and Kayak article”), then hitting Enter adds a new goal embodied in the view as a green button. When users complete a goal, they click its button which turns dark brown. Hitting the Clear button clears the completed goals from the view and from the underlying model. Pretty simple compared to all those Outlook or iCal models, but effective and far more likely to be used. The first line connects the three controller functions to the three classes in Listing One. The second starts the application itself. When the user enters a new goal, the browser shifts control to the ToDo controller function. The controller classes implement get or post functions; this too should be familiar to you. ToDo and MarkDone both transfer control using a redirect to “/” which is handled by the MainPage class. Using Django Templating In MainPage, the controller code then does a little behind the scenes AJAXian magic to correctly return the page, as seen by the user, replacing the parts of the page’s DOM without refreshing the entire page. By convention, the default application view is contained in index.html; see Listing Two (available online). An interesting code snippet from index.html is: {% for entry in todoList %} {{ entry.status }} | {{ entry.content|escape }} {% endfor %} Google Application Engine While AWS concentrates on computing resources, the Google Application Engine (GAE) focuses on computing capabilities released via the Google SDK. At this writing, GAE is in preview, but the parts of the overall concept already revealed have stunning appeal. What would your life as a developer be like if you could focus 100 percent of your energy on the business end of your RIA, rather than fretting the details of what happens when you actually attract a significant user base? This is the promise of GAE. By leveraging an agile language (Python) and well-known RIA framework (Django), application development is a matter of fast iterative, incremental coding. GAE is built on a Web 2.0 infrastructure built on a custom (but open) API. When you download the SDK (code.google.com/ appengine), you get a local webserver environment suitable for code development and light use testing. The SDK: The Code What’s compelling about GAE is the level of abstraction at which you code. An application’s code logic can often be a single Python file, with class definitions for the data model, and individual classes implementing the handlers for the various HTTP POSTs and GETs, as in Listing One (available online; see “Resource Center, page 4). Examining Listing One, notice that there is a class (ItemEntry) whose parent class is db.model and another three descended from webapp.RequestHandler. These latter three Figure 7: SSH connection. If you have worked in Rails, TurboGears, Django, or the like, this is probably familiar. Essentially, this segment contains a code directive that the underlying GAE code resolves prior to display. When the GAE code encounters The {% %} pairs, signal the controller method to interpret the text between delimiters as Python code. Controller class methods return multiple values as a Python dictionary. Wherever it encounters variables appearing between pairs of curly braces, the underlying Django engine substitutes values from the dictionary into the correct template slots in 20 Dr. Dobb’s Journal l www.ddj.com l February 2009 http://code.google.com/appengine http://code.google.com/appengine http://www.ddj.com
Table of Contents Feed for the Digital Edition of Dr. Dobb's Journal - February 2009 Dr. Dobb's Journal - February 2009 Contents Friday Night Fish Fry Alia Vox Developer Diaries Conversations Computing in the Clouds Software Development in the Cloud Videos and Oracle Forms 10g Parallel LINQ Decoupling C Header Files Effective Concurrency Disciplined Agility Swaine’s Flames Dr. Dobb's Journal - February 2009 Dr. Dobb's Journal - February 2009 - (Page BB1) Dr. Dobb's Journal - February 2009 - (Page BB2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page Cover1) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page Cover2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 1) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 3) Dr. Dobb's Journal - February 2009 - Contents (Page 4) Dr. Dobb's Journal - February 2009 - Contents (Page 5) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 6) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 7) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 8) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 9) Dr. Dobb's Journal - February 2009 - Alia Vox (Page 10) Dr. Dobb's Journal - February 2009 - Alia Vox (Page 11) Dr. Dobb's Journal - February 2009 - Developer Diaries (Page 12) Dr. Dobb's Journal - February 2009 - Developer Diaries (Page 13) Dr. Dobb's Journal - February 2009 - Conversations (Page 14) Dr. Dobb's Journal - February 2009 - Conversations (Page 15) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 16) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 17) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 18) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 19) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 20) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 21) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 22) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 23) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 24) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 25) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 26) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 27) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 28) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 29) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 30) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 31) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 32) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 33) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 34) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 35) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 36) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 37) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 38) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 39) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 40) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 41) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 42) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 43) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 44) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 45) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 46) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 47) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page 48) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page Cover3) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.