Bruno, This is a good article. I have done something like this before. My approach was a bit different. I was using the singleton pattern, but I think it accomplishes the same goal.
I would for example have a module like this: from gluon import * class MyModel(object): instance = None def get(db): if instance is None: instance = MyModel(db) return instance def __init__(self, db): db.define_table(....) Then I would still have a db.py for a model, but I would replace the usual db.define_table() with this: from mymodel import MyModel MyModel.get(db) This ensures that the tables only get defined once on the first request after starting web2py. I have used this approach on other code that I needed to keep alive for other requests.