Controller actions (i.e. actions displayed in URLs) must be functions defined in the controller file (i.e. you cannot move them to a module). However, if the controller has functions that are not actions, you can transfer them to the module. Assuming you call these functions from a model or controller, you can simply pass the db , me and now objects for these functions as arguments. Another option is to add them to the local current stream object, which can be accessed from the modules. For this:
In the model:
from globals import current current.app.db = db
In the module:
from globals import current def func(*args): db=current.app.db
source share