Why don't you use the module directly (as stated earlier, models are Singletons). If you create a module, for example:
# mymodule.py from mydb import Connection connection = Connection('host', 'port')
you can use the import mechanism, and the connection instance will be the same everywhere.
from mymodule import connection
Of course, you can define a much more complex initialization of connection (perhaps by writing your own class), but the fact is that Python will only initialize the module once and provide the same objects for each subsequent call.
I believe that Singleton (or Borg) templates have very specific Python applications, and for the most part you should rely on direct import until proven otherwise.
source share