psu improvments for db and conn usage; fix table.py

This commit is contained in:
Helmut Merz 2024-10-25 15:08:08 +02:00
parent 14ea59a307
commit 0f2232648c
2 changed files with 13 additions and 5 deletions

View file

@ -43,22 +43,30 @@ except ImportError:
sc = Jeep() # shortcuts
db = None
conn = None
def closeConnection():
global conn
if conn is not None:
print('closing ZODB connection...')
conn.close()
conn = None
atexit.register(closeConnection)
def setup(zope_conf=None, loopsRootPath=None, config=config):
if zope_conf is None:
zope_conf = getattr(config, 'zope_conf', 'zope.conf')
if loopsRootPath is None:
loopsRootPath = getattr(config, 'loops_path', None)
global conn, root, sm, smdefault, intids, pau, loopsRoot, sc
print(f'opening ZODB connection... - conf: {zope_conf}, path: {loopsRootPath}')
conn = wsgi.config(zope_conf).open()
atexit.register(closeConnection)
global db, conn, root, sm, smdefault, intids, pau, loopsRoot, sc
if db is None:
print(f'setting up ZODB... - conf: {zope_conf}, path: {loopsRootPath}')
db = wsgi.config(zope_conf)
if conn is None:
print(f'opening ZODB connection...')
conn = db.open()
root = conn.root()['Application']
setSite(root)
sm = component.getSiteManager(root)

View file

@ -131,7 +131,7 @@ def getRowValue(k, v):
return v[0]
def getRowValueWithKey(k, v):
return ' '.join((k, v[0]))
return ' '.join((str(k), v[0]))
@implementer(IIterableSource)