Search Posts

Author: pyadmin

web2py tutorial: Show user ID as name instead of integer

This web2py tutorial shows these main concepts: How to represent an integer quantity in the database, such as a user ID, as a string How to use multiple tables in a form How to use something other than a default SQLFORM widget These concepts are illustrated by creating a highly simplified tasks database consisting of nothing but a description and a title. When you create a record, you assign the task to an existing user […]

web2py tutorial: Using the Datatable jQuery grid plugin with web2py

The DataTable jQuery plug-in from DataTables.net is a very fast, configurable grid control. It has built-in pagination, search (including incremental search, where the grid shrinks as you type each letter, reducing the grid size as you refine the search term), sorting by column, and multiple theming options, among them jQueryUI, Bootstrap, and Foundation. It works beautifully with web2py when you’ve cracked its secrets. DataTable very easy to use–if you already know howt! Sort of like […]

web2py SPA tutorial: Creating a single-page application with web2py using LOAD

Using LOAD to insert HTML dynamically into an existing page One way to speed up web applications is to load only part of a web page at a time using jQuery. You insert HTML into a running page using web2py’s versatile LOAD helper. This example creates a simple todo list application. What makes it different from a stock web2py app is that while the index() view displays a grid of all the existing tasks, it […]

web2py Handsontable tutorial #1: Populating a Handsontable grid using web2py

Updated 5/9/2015: replaced obsolete CRUD class with SQLFORM, changed CDN, and reformatted code to fit narrower viewports This tutorial shows how to create a data entry form for a To Do app in web2py and to display all To Do records on the home page using a Handsontable control. Handsontable is an Excel-like grid control written in Javascript. It’s one of those commercial-quality products that happen to be available free. From the web2py admin interface, create an […]

web2py shortcuts

Eliminate intermediate variables Not yet sure if this is considered idiomatic web2py or Python, but you can replace this: With this, which eliminates a variable and saves a function call. Probably considered more C style than Python:

Why you should automate EVERYTHING or: Your first job is to be boring

My current project is taking forever to get off the ground, and that’s fine, because I’m automating everything I can. That means at any time I must be able to wipe out the old site, provision a server, and deploy the new site within minutes, with me having to do little more than run a file and fill in a few passwords. Obviously there are a lot of good reasons to automate, but the primary […]

web2py one to many database tutorial using SQLFORM.smartgrid

This web2py tutorial has everything you need to create a To Do list featuring a list of users stored in one table, a task database stored in another table, and how to create a one to many relation ship between a user and that user’s list of tasks. It is a complete, feature-rich, database-backed web application and is very near production ready in a total of  about 20 lines of Python and about 30 lines of […]

web2py grid vs. smartgrid

The web2py SQLFORM.grid and SQLFORM.smartgrid controls sound like one should be a subset of the other, but they aren’t. web2py grid vs. smartgrid: Similarities Both the grid and smart grid controls can browse, search, sort, create, update and delete records. Both can accept a table as the first parameter web2py grid vs. smartgrid: Differences Here’s a summary of important differences. The web2py grid First argument: Table or query The web2py smartgrid First argument: Table only (not query) […]

web2py performance

Notes on improving web2py performance. This will be improved later. Lazy Tables According the docs (Lazy Tables, a performance boost), “web2py models are executed before controllers, so all tables are defined at every request. Not all tables are needed to handle each request, so it is possible that some of the time spent defining tables is wasted.”