I use explicit imports combined with the use of the 'current' object.
from gluon import (
current, DAL, redirect,
URL,
Field,
LABEL,
DIV,
SPAN,
HTTP,
P,
CAT,
H3,
XML,
IS_EMAIL,
IS_DATE,
IS_DATETIME,
IS_LENGTH,
IS_IN_DB,
# IS_NOT_IN_DB,
IS_NOT_EMPTY,
IS_EMPTY_OR,
IS_LOWER,
IS_EXPR,
IS_UPPER,
IS_IN_SET,
IS_INT_IN_RANGE,
IS_FLOAT_IN_RANGE,
)
from gluon.sqlhtml import SQLFORM
from gluon.storage import Storage
request = current.request
response = current.response
session = current.session
cache = current.cache
settings = current.app.settings
T = current.T
...
# after creating the db using db = DAL()
current.app.db = db
# same for the Auth() instance (and a settings object)
current.app.auth = auth
In a controller:
from gluon import (
current,
SQLFORM,
Field,
IS_IN_SET,
IS_NOT_EMPTY,
IS_INT_IN_RANGE,
IS_UPLOAD_FILENAME,
redirect,
URL,
TEXTAREA,
A,
UL,
LI,
P,
B,
SPAN,
PRE,
DIV,
INPUT,
FORM,
TABLE,
TH,
TR,
TD,
)
# from gluon.sqlhtml import SQLTABLE
from gluon.storage import Storage
db = current.app.db
request = current.request
response = current.response
session = current.session
cache = current.cache
page = current.page
scheduler = current.app.scheduler
T = current.T