Monday, June 4th, 2012

Book Review: Web2Py Application Development Cookbook

If you are not familiar with Web2py, it is a complete Python web framework, which does not depend on any external packages. It is provided in a stand-alone download for all popular operating systems, which allows a developer to begin working on the web application as soon as the download finishes. This review is not about Web2Py, but more specifically a book written by multiple authors who have worked with Python for many years. One author to note is Massimo Di Pierro, who was the individual who started the Web2Py project in 2007, and is currently the lead developer.

When I first opened the book, I glanced over the Table of Contents, and got immediately excited about reading these many topics. Since this is a book in the Cookbook series, each section is a Recipe. It is targeted to developers who know at least a little about Web2Py, and Python in general. It does not go through any Python basics, and has only a few examples of basic Web2Py applications. That being said, if you know almost nothing about Web2Py, as I did when I first began reading this book, it can be a great starting point.

The recipes provided mostly do not provide any detailed explanation on what each line does, a few more complex examples do explain some of the code however. The book assumes that you can easily read Python code and follow along. You may wish to have a copy of the Web2py book next to you for reference. That being said, it goes through some topics which some users have expressed difficulty with when using web2py. Such as adding a custom logo to your application, and customizing the menus in various ways.

The basic introduction to web2py in the book begins with the deployment, I personally believe that the deployment section should have been near the end of the book. It explains some rather complex deployment options, which can be very handy to have next to you. Such as deploying to IIS using 2 popular methods, a proxy, and by using ISAPI. More traditional deployments are also explored, it goes through the following popular server software: Apache, Lighttpd, Cherokee, Nginx with uWSGI, and of course CGI. I found this chapter very enlightening, as it explains the deployment options very clear and in easy to follow steps.

The second chapter goes through some very basic applications, and how they would be constructed. The example code provided throughout the book can also be downloaded from the publishers website for use and reference. Due to the layout of the book, the code blocks do not wrap around correctly. As we are dealing with Python here(No curly brackets), some code examples can be very difficult to follow from the book. I attempted to read the book in both Okular(KDE's PDF/PS viewer), and the latest version of Adobe Reader on Windows 7. In both instances, the code examples were sometimes hard to follow. This might not be the case for the printed version. Despite this, Packt Publishing does provide the code examples for download, so this shouldn't be too much of a problem. Considering how good the examples in the book are, I won't hold this against the book.

The basic application in the second chapter begins with a simple scaffolding application, which is used for the remainder of the examples in the book. Unfortunately, the version of web2py the scaffolding application targets, makes it difficult to fully implement in the current version. Most of the changes provided are already included in the latest version of web2py, and thus the example has settings which contradict the newer web2py scaffold. However, you can download the code from the publishers website and use that, so this is just trivial.

I found chapter 2 to be the most enlightening, as they provide examples for already existing websites, such as Reddit and Facebook. Oddly enough, there was no Twitter example, which can sometimes be the most overused example. Later in the book, it also explains how to implement Facebook authentication, however it seems to lack Twitter authentication. It seems that the authors are not huge fans of twitter, or there wasn't enough time to add a Twitter authentication section. Definitely not a showstopper, but it is something that I would have liked to see.

The second chapter continues with other essentials to web2py, such as explaining how crud.archive works, which is very nice to know, and how to convert an existing static website to a web2py application. The chapter finishes with an improvement to the download function in web2py.

The book is overall well organized and it is very easy to find the recipe you need to reference. For someone new to the series, I found it to be much different than a traditional book. The cookbook series focuses on code examples, rather than explaining every single detail. For those people who learn best with example code, you will not be disappointed here. If your style of learning requires each and every step explained to you along the way, you should look into other books on the subject first.

The book also has a very interesting code example at the end of the book, Making standalone applications with web2py and wxPython. I thought it was an odd subject for a book about web development, but it is a rather fun example, and does show potential.

The book has recipes for implementing the latest in web technology, and has a chapter dedicated to AJAX, and various effects you can do. This section includes code for new widgets which you can use in your own applications. These widgets are provided as plugins, so they can be moved between applications.

Another section which I really liked to see is the section on routing. I do wish it explained more customized routing examples, the recipes included are quite general. Something which would have complimented the static site to web2py app section would have been a route to mimic the past website. As this would prevent any prior links from breaking.

They also include a section on web services, which explain how to create and use external web services in your application. An example for legacy SOAP services is also included, which is nice to know. Overall the web services examples are very helpful, especially when your planning on deploying your own API.

In conclusion, this book has changed my overall view of Web2py as a framework. Before reading this book, I did not have any additional plans to learn and use Web2Py. This book has given me a new respect for this framework, which will make me consider using it in future projects. Do look forward for an entire review of the Web2Py platform in the coming weeks. There are many features which Web2Py offers, which other major frameworks do not yet provide. This book clearly outlines what Web2Py can do, and how to do it right. I will definitely recommend this book to anyone who has Python experience, and knows at least some Web2Py.


  • Well organized
  • Lots of real-world usable code recipes
  • Facebook authentication recipe
  • Includes great deployment recipes for multiple platforms


  • Book is too thin for code examples to be easily readable
  • No Twitter authentication recipes

You can buy this book directly from the publisher.

Comment #1: Posted 9 years, 4 months ago by Manikandan

Great review! Thanks a lot!

About Me

My Photo
Names Kevin, hugely into UNIX technologies, not just Linux. I've dabbled with the demons, played with the Sun, and now with the Penguins.

Kevin Veroneau Consulting Services
Do you require the services of a Django contractor? Do you need both a website and hosting services? Perhaps I can help.

This Month

If you like what you read, please consider donating to help with hosting costs, and to fund future books to review.

Python Powered | © 2012-2019 Kevin Veroneau