I didn't understand your approach completely, if I have globals
variables/callables like ${g} and ${h}, why would I need another
wrapper (variable_provider)? With Helpers and Globals I'm covering
all my bases right now. Maybe I misunderstand your point.
What I need to know is, which is the best-place/practice to initialize
a global, or any application wide variable, which value is stored in a
table. The rootcontroller maybe? with a boolean global which I set to
True after initializing so it only happens once? also, What if I
change a value? I need a way to reset those globals programatically.
Don't get me wrong here, maybe I'm used to the way it works on Java.
In Java, I have 'listeners' in which I can write a function called
'setupContext' which loads all my globals any time I want, so if I
change a setting of the application, like 'send_confirmation_email' to
false, and then call 'setupContext' the next time a user registers it
wont send a confirmation email.
Juan Pablo
On Oct 6, 2:42 am, "Diez B. Roggisch" <[email protected]> wrote:
> Juparave schrieb:
>
> > Crusty,
>
> > May I ask another question? Remember that global variable we where
> > talking about?
> > Where do you recommend to initialize it if my value is stored in a
> > settings table? Tried to initialize it inside Globals but it sends an
> > error:
>
> > sqlalchemy.exc.UnboundExecutionError: Could not locate a bind
> > configured on mapper Mapper|Settings|settings, SQL expression or this
> > Session
>
> > My guess is that Globals is initialized before database binding, so
> > there must be a place where I can initialize this and any other global
> > variable, isn't it?
>
> It's called "variable providers". There is no real location for these,
> but I put it into the root of my template-dir as file
> "variable_provider.py".
>
> In there, I define one callable, again "variable_provider", which
> returns a dict.
>
> This then gets imported in "config/app_cfg.py" and there is a line
>
> base_config.variable_provider = variable_provider
>
> This will make sure that in all templates, I have (under no special
> scope, top-level) the returned names/objects available.
>
> I'm not sure if that's part of the quickstart-template yet, might be
> worth considering.
>
> Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---