It is standard practice to only close the connection when the request is complete, yes.
Postpone the close to the latest possible moment. Use could use a context manager to handle the closing for you:
from contextlib import contextmanager
@contextmanager
def zodbconn(db):
conn = db.open()
yield conn.root()
conn.close()
then use:
with zodbconn(db) as zconn:
return template.render(args....)
and the connection will be closed automatically after the return
statement has been processed.