Dear all,

I'm having troubles accessing DB data from a function registered as a 
startup hook in my TG2 application.

Minimalist code to illustrate:
def on_startup():
    print DBSession.query(User).count()

tg.hooks.register('startup', on_startup)


It works like a charm in a shutdown hook, but in the startup hook an 
exception is raised: "*UnboundExecutionError: Could not locate a bind 
configured on Mapper|User|user, SQL expression or this Session.*".

I understand in this case the DBSession is not ready when the startup hook 
is called, but I don't see another hook that would fit.
I defined the hooks in *app_cfg.py*, as I understand this is the common 
practice. Should the startup hook be defined elsewhere in that case?

Thank you and best regards,
-- 
Piotr PAWLICKI

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to turbogears+unsubscr...@googlegroups.com.
To post to this group, send email to turbogears@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to