Wednesday, May 30, 2012

Review: Web2Py Application Development Cookbook

Changing things up a bit, today I have a special treat, as Jay Kelkar, an avid Pythonista and fellow member of the Python Atlanta user group, has agreed to write a guest post reviewing the web2py Application Development Cookbook. If you give him half a chance, Jay will be happy to expound upon the benefits of Web2Py, so this review seemed a perfect fit for him. So without further introduction, here's Jay's review (full disclosure: the Amazon links below are affiliate links):

For years I have been focused in making things easier for users while putting attention on important matters . I have been interested in all things Python for over 10 years. There are many Python frameworks available and most are libraries with suggestions on how to use them to create web applications. Then web2py came to my notice, a Python web framework which does things quite differently from other popular web frameworks. The two features that put it above the others are: the developer deals more with the problem at hand and rather than the framework, and the built in ability to allow switching between major databases with very little effort. I have been using web2py for over 3 years and have written several major applications with web2py. I wondered if I would find in the book anything that would make me sit up and take notice. So it is with this in mind that I review web2py Application Development Cookbook by Mariano Reingart, Bruno Cezar Rocha, Jonathan Lundell, Pablo Martín Mulone, Michele Comitini, Richard Gordon, and Massimo Di Pierro (the lead developer for web2py).

Web2py is unique in many respects and what is positive to one programmer may appear negative to another. Some of the distinguishing characteristics follow. It is based on the MVC principle - which states that the Model which describes the data and its access, the View which displays or renders the data, and the Controller which manipulates the data, are kept separate and distinct. Unless you want to do something out of the ordinary, no modules need to be imported. It's ORM is distinctly SQLish, so anyone familiar with SQL will feel completely at home. Another is that it will automatically update the database schema to the model on request - this can be desirable in development. It can host multiple apps under one server. In addition, it requires no installation and is ready to run after it is unzipped into the target directory.

Summary

This is a good book. It is aimed at users who are somewhat familiar with web2py and Python. It has a good breadth in popular areas of interest and in most cases gives a good in-depth treatment to each with explanations of how things actually work. It assumes that you are familiar with web2py and Python. Some knowledge of JavaScript, HTML and CSS will also be helpful but not absolutely necessary. If you want to learn web2py I would instead point you to http://web2.py.com/book, which is the preferred source for web2py documentation online. This book does not pretend to teach Python, JavaScript, HTML or CSS. If you are new to Python, this is definitely not the book for you.

Synopsis

This book is partitioned into chapters each of which has a central theme and in each chapter they present a list of items covered. This book, while being a great learning resource, will be a very handy reference in cases that are not common to most apps but are important when needed. Examples like PayPal integration, auth using FaceBook, and archiving database updates instantly come to mind. The web2py framework is under active development and since the documentation lags the software, it is impossible to know all the latest goodies in web2py unless you live on the developer newsgroup. I was pleasantly surprised at the new nuggets of functionality I found.

The book opens with a detailed treatment of issues related to getting web2py ready for production use. The depth gives us an idea of the level of detail we can expect from the rest of the book. It shows how it is possible to run web2py behind virtually every major popular web server and how to make it secure.

Even though some familiarity with web2py is assumed, it proceeds to give a thorough account of how to build applications on web2py in Chapter 2. Instead of the usual applications like to-do list or a simple comment system, it shows applications that are useful even after their value for learning is over.

In Chapter 3, the Database Abstraction Layer is explained at length. Many examples are given to illustrate its power and to show how it meets programmer's needs. This chapter also covers generating a model from an existing MySQL and PostgreSQL database, which helps if web2py is being used to create an app based on an existing database. This effectively shows the power of DAL while showing how to leverage it to do most commonly required tasks.

In Chapter 4, the focus is on an advanced version of forms. Forms can be easily generated using web2py, however this chapter deals with needs that are often just beyond normal forms or for items in a form that do not necessarily relate to data. Examples include adding Cancel buttons to a form, forms for uploading files and creating forms with fields originating from more than one table.

Chapter 5 deals with using Ajax to enhance widgets. It also talks about ways to use fancy widgets to display tabular data with full Ajax support.

In Chapter 6, the book shows how to integrate third party libraries with web2py, showing among other uses how to customize logging, working with tweets and using matplotlib.

Chapter 7 brings us ideas on working with services with web2py. In examples shown you can see how easy it is to consume a variety of services. Like JSON from web2py using jQuery, making RPC calls from Flex, integrating PayPal service, or creating SOAP web services.

Chapter 8 deals with authentication and authorization, it explains how to use the auth system in web2py and gives several ways to implement authorization in the apps. Authenticating with Facebook is a very useful recipe because Facebook is so popular.

Chapter 9 and 10 bring you ideas on routing and reporting. It is possible to route within web2py or outside it using a web server. Examples are given with detailed explanations of how this is done for various situations. The chapter on reporting mainly deals with converting the displayed page to pdf and other related ideas.

Chapter 11, the final chapter, is a repository for all recipes which did not fit into any of the above topics. I particularly liked knowing how to debug a running app on the web using the embedded web2py debugger. They also show miscellaneous tips and tricks which come in handy.

Conclusion

Having contributed to the web2py framework itself, the authors have a vast amount of experience and the book shares what they know in a very useable format. Code is explained in some detail where necessary and the code was included with the book I reviewed. There are a few errors in the text and small examples shown. The book shows how to use web2py to solve most common and many not so common needs while writing web apps. The book is interesting to read and easy to follow. I did find some code discussed to take up too much space, almost distracting from the flow. However, had I been interested in that recipe, I am sure I would have welcomed the detailed treatment given to the topic. This book will prove a good addition to a web2py user's library.

About the Author

Jay Kelkar has 30 years experience in programming and web development. He has a Master's degree in Computer Science from University of SouthWestern Louisiana at Lafayette and a Bachelor's degree in Pure Math from Southern Illinois University at Carbondale. His professional interest is in solving problems. His experience includes programming Class 5 telecom switches, programming at all levels on many UNIX platforms (OS, apps, X11 and scripting), and on MS Windows he sticks to programming in portable languages: mostly Python and Ruby. He was an SAP Basis Consultant for 15 years where he connected SAP with many other systems and solving problems that go with running a large system. His area of expertise includes all kinds of software tools, large databases, data interchange and making it easy for users to get work done.

3 comments:

  1. Anonymous1:21 AM

    This comment has been removed by a blog administrator.

    ReplyDelete
  2. Thanks for the review. I am buying the book (PDF+print) as we speak :)

    ReplyDelete
  3. Alec,

    Thanks for the comment! Glad you enjoyed it!

    ReplyDelete