Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8210069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:56:50+00:00 2026-06-07T09:56:50+00:00

Possibly related topic, but from which I could not solve the problem: How to

  • 0

Possibly related topic, but from which I could not solve the problem: How to initialize global variables in TurboGears 2 with values from a table

The issue is that I’m trying to read some config parameters from the database when initializing some of the global variables in app_globals.py in Turbogears.

When attempting to access the database however, I receive an exception:

sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper Mapper|Config|config_table, SQL expression or this Session

Just as the exception states this is probably due to the db not being bound yet (global parameters are set up first). From the other topic I was pointed in the direction of going to app_cfg.py and using “on_startup” to bind the database before initializing the global variables, but it’s not working for me. Either I’m not doing it right or this is not the solution to the problem. For instance, I tried writing:

def on_startup():
    print "Foo bar!!!"

base_config.register_hook('startup', on_startup)

But the print statement is never executed (the crash occurs before).

Does anyone have any pointers on where to go from here?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:56:52+00:00Added an answer on June 7, 2026 at 9:56 am

    You can use the after_config hook to call a setup method in your app_globals which gets to the database and retrieves the data it needs to set itself up.

    after_config hooks is actually called after the full turbogears application got configured and so you will have both app_globals and the database built and configured. You can access app_globals from the hook using config['tg.app_globals'] or config['pylons.app_globals'] depending on which version of TG you are using.

    Pay attention that the after_config hook has to return the turbogears application itself, so just return the parameter you get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possibly related question: How could I generate a contextual text extract from text returned
There is another possibly related question on this but it didn't have answers and
a possibly simple problem, but weird why I have no idea how to do
I browsed through all kinds of post related to this topic but the answers
Possibly related to Git - pulling changes from clone back onto the master I
I'm not sure if this is on-topic or not here, but it's so specific
Possibly a dumb question, but I'm more used to Java and the likes and
Possibly a silly question, but I'm having no luck finding an answer. Using Visual
What could possibly cause this weird python behaviour? Python 2.6.2 (r262:71600, May 31 2009,
This could quite possibly be the dumbest question ever asked. Our client wants us

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.