On Jun 17, 2006, at 10:31 PM, Arnold wrote:

>
> Thank you Alberto,
>
> I tried with "tg" but it seems that on my TG version std is still
> correct.
> In fact my gaol is to set the tg_js path by myself because I want to
> choose the directory where I install the js librairies. According to
> your answer, I understand that this path is set statically in the TG
> code. So, I have found where to change this path in the TG code (in  
> the
> startup.py file in the /usr/lib/python/site-packages/turbogears... )
> but I don't like this solution. I understand your proposal to place  
> the
> path in the returned dictionnary to the template, it's flexible but
> requires systematic coding.
> So, I am a little bit disapointed and still not sure that I understand
> the use of this variable.
> Does that make sense to you ? I will be glad to read your opinion.
> Thank a lot for your help.
> Arnold
>

You don't need to change this path (and shouldn't) because it's where  
TG's static files (Mochikit, etc...) live and some unexpected  
behavior (like being unable to access TG's bundle Mochikit) might  
happen.

Your app's static directory is already registered at config/app.cfg  
so any access to {webroot}/static/ will map there.
To access anything there you should link to it like:
${tg.url("static/javascript/my.js")}

Remember to use tg.url so the full path gets computed correctly (just  
in case your webroot isn't "/")

If you want to add another different path just add another block in  
app.cfg (take the [/static] block as inspiration).

To make a reference to this path available to all templates without  
needing to return it in every controller you can do this by adding a  
variable provider:

from turbogears import url
def my_var_provider(d):
        d.update(my_js_path = url("foo/bar/js"))

from turbogears.view import variable_providers
variable_providers.append(my_var_provider)

Now from your templates you can use ${std.my_js_path}/whatever.js.  
Again, remember to send the path via the "url" function so it gets  
computed correctly.

HTH,
Alberto


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to