PacktLib: web2py Application Development Cookbook

web2py Application Development Cookbook


About the Authors and Reviewers

About the Reviewer


Deploying web2py


Installing web2py on Windows (from source code)

Installing web2py in Ubuntu

Setting up a production deployment on Ubuntu

Running web2py with Apache, mod_proxy, and mod_rewrite

Running web2py with Lighttpd

Running web2py with Cherokee

Running web2py with Nginx and uWSGI

Running web2py on shared hosts using CGI

Running web2py on shared hosts with mod_proxy

Running web2py from a user-defined folder

Installing web2py as a service in Ubuntu

Running web2py with IIS as a proxy

Running web2py with ISAPI

Building Your First Application


Improving the scaffolding application

Building a simple contacts application

Building a Reddit clone

Building a Facebook clone

Using crud.archive

Converting an existing static site into a web2py application

Creating semi-static pages (flatpages)

Adding your custom logo

Creating menus and submenus

Customizing menus with icons

Creating a navigation bar

Using cookies to set the language

Designing modular applications

Speeding up downloads

Database Abstraction Layer


Creating a new model

Creating a model from a CSV file

Batch upload of your data

Moving your data from one database to another

Creating a model from existing MySQL and PostgreSQL databases

Efficiently searching by tag

Accessing your database from multiple applications

Hierarchical category tree

Creating records on demand

OR, LIKE, BELONGS, and more on Google App Engine

Replacing slow virtual fields with DB views

Advanced Forms


Adding confirmation on form submit

Searching data dynamically

Embedding multiple forms in one page

Detecting and blocking concurrent updates

Creating a form wizard

De-normalizing data temporarily

Removing form labels

Using fileuploader.js

Uploading files using a LOADed component

Making image thumbnails from uploaded images

Monitoring upload progress

Auto tooltips in forms

Color picker widget

Shortening text fields

Creating multi-table forms

Creating a multi-table form with references

Creating a multi-table update form

Star rating widget

Adding Ajax Effects


Using jquery.multiselect.js

Creating a select_or_add widget

Using an autocompletion plugin

Creating a drop-down date selector

Improving the built-in ajax function

Using a slider to represent a number

Using jqGrid and web2py

Improving data tables with WebGrid

Ajaxing your search functions

Creating sparklines

Using Third-party Libraries


Customizing logging

Aggregating feeds

Displaying Tweets

Plotting with matplotlib

Extending PluginWiki with an RSS widget

Web Services


Consuming a web2py JSON service with jQuery

Consuming a JSON-RPC service

JSON-RPC from JavaScript

Making amf3 RPC calls from Flex using pyamf

PayPal integration in Web2py

PayPal web payments standard

Getting Flickr photos

Sending e-mails with Boto through Amazon Web Services (AWS)

Making GIS amps using mapscript

Google groups and Google code feeds reader

Creating SOAP web services

Authentication and Authorization


Customizing Auth

Using CAPTCHA on login failure

Using pyGravatar to get avatars for user profile pages

Multi-user and teacher modes

Authenticating with Facebook using OAuth 2.0

Routing Recipes


Making cleaner URLs with

Creating a simple router

Adding a URL prefix

Associating applications with domains

Omitting the application name

Removing application name and controllers from URLs

Replacing underscores with hyphens in URLs

Mapping favicons.ico and robots.txt

Using URLs to specify the language

Reporting Recipes


Creating PDF reports

Creating PDF listings

Creating pdf labels, badges, and invoices

Other Tips and Tricks


Using PDB and the embedded web2py debugger

Debugging with Eclipse and PyDev

Updating web2py using a shell script

Creating a simple page statistics plugin

Rounding corners without images or JavaScript

Setting a cache.disk quota

Checking if web2py is running using cron

Building a Mercurial plugin

Building a pingback plugin

Changing views for mobile browsers

Background processing with a database queue

How to effectively use template blocks

Making standalone applications with web2py and wxPython