wiki:DeveloperGuidelines/Web2pyInternalsAndTips

Version 7 (modified by Pat Tressel, 9 years ago) ( diff )

--

This is a collection of tips extracted in part by reading the Web2py code.

gluon.dal

DAL

DB Adapters

Table

Get DAL object given a Table object (in table):

table._db

Get names of fields in a table:

table.fields()

Get Field objects from a table (field name in fieldname):

table[fieldname]

Read out the whole table:

table._db().select(table.ALL)

Clear the table (caution, requires foreign key constraints turned off):

table.truncate()

Load table from a Rows object (e.g. as obtained by reading out the table as above) or from a list of dicts:

table.truncate()
for row in rows:
    if isinstance(row, Row):
        row = row.as_dict()
    table.insert(**row)

Field

Environment

Custom Import

Form accepts

Validation

Note: See TracWiki for help on using the wiki.