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?

Thanks

On Oct 5, 5:41 pm, Juparave <[email protected]> wrote:
> Excellent link, now I feel more comfortable with this, I don't know
> how I missed it in the tutorial.
>
> Greetings, Juan Pablo
>
> On Oct 5, 10:44 am, Crusty <[email protected]> wrote:
>
> > Hey there,
>
> > Yea its not exactly inutitive, but you might also want to take a look
> > at the helpers, really nice stuff there. anything in helpers can be
> > accessed in templates via h.foo()
>
> > this link is extremely helpful:
>
> >http://pylonshq.com/docs/en/0.9.7/views/#default-template-variables
>
> > Greetings, tom
>
> > On Mon, Oct 5, 2009 at 5:14 PM, Juparave <[email protected]> wrote:
>
> > > Thank you Crusty, I never ever entered the lib directory, never
> > > thought that a global variable definition could be inside a lib.
>
> > > It works, easy as pie.
>
> > > On Oct 5, 6:22 am, Crusty <[email protected]> wrote:
> > >> Tiny correction: its lib/app_globals.py
>
> > >> but i guess you could have figured that out on your own ;)
>
> > >> On Mon, Oct 5, 2009 at 1:15 PM, Crusty <[email protected]> wrote:
> > >> > Hello there,
>
> > >> > Thats what lib/global.py is there for ;)
> > >> > In templates you can access anything in there via g.foo(), if there is
> > >> > a function foo() present in globals.
> > >> > In other code you just have to import it regularily iirc.
>
> > >> > Greetings,
> > >> > Tom
>
> > >> > On Mon, Oct 5, 2009 at 8:51 AM, Juparave <[email protected]> wrote:
>
> > >> >> Is there a way to store an application wide variable?  Maybe is not a
> > >> >> best practice in python, I'm just trying to see if I can move some
> > >> >> project from java to python and I got to my first problem.
>
> > >> >> How can I define and access a variable from the templates (I'm using
> > >> >> the default's Genshi) for something like the path where the images are
> > >> >> stored without sending the variable on each controllers function.
>
> > >> >> i.e.:
>
> > >> >> <img src="${app_config.PATH_TO_IMAGES}/${p.image}" />
>
> > >> >> or how can I get session variables from the template as well.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to