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



Alberto Valverde wrote:
> Duh, had a typo in the code I sent. std.tg_js points to TG's js
> static drectory, so Mochikit lives at ${std.tg_js}/Mochikit.js. (not $
> {std.tg_js}/js/Mochikit.js)
>
> The "std" variable is sent to every template by TG, you don't need to
> explicitly set it, just access it from the template and you're done.
>
> BTW, IIRC "std" has been deprecated in favor of "tg", so it should be
> ${tg.tg_js}.
>
> Hope it makes things a little bit clearer,
>
> Alberto
>
> On Jun 17, 2006, at 4:58 AM, Arnold wrote:
>
> >
> > Thank you Alberto,
> > My problem is to set the std.tg_js variable.
> > I am new in Python/Turbogears and I don't understand how to write the
> > code to set the value of this variable.
> >
> > I import the view module in the controllers file like this:
> >
> > import turbogears
> > from turbogears import controllers
> > from turbogears import view
> >
> > std.tg_js="static/javascript"
> >
> > class Root(controllers.Root):
> >     @turbogears.expose(html="newgears.templates.welcome")
> >     def index(self):
> >               return dict()
> >
> > This doesn't work, I get the message : NameError: name 'std' is not
> > defined
> > I also tried "view.tg_js="static/javascript" which is accepted at
> > compile time but generates an error at  run time.
> >
> > Do you know what is already set by default in Turbogears and what I
> > should  set by myself ?
> >
> > Thanks for your help
> > Arnold
> >
> > I had a look at the stdvars documentation, but
> >
> > Alberto Valverde wrote:
> >> On 11/06/2006, at 18:04, Arnold wrote:
> >>
> >>>
> >>> Dear All,
> >>> I have not found how to set up std.tg_js variable
> >>> I suppose it shall be set to the path where is located the MochiKit
> >>> library (relative to the project root directory) (<script
> >>> src="${std.tg_js}/MochiKit.js"/>)
> >>> May be I am missunderstanding something ??
> >>
> >> std.tg_js points to the turbogears static files directory which is at
> >> turbogears/static. Mochikit.js lives in turbogears/static/js/
> >> Mochikit.js so you should write.
> >>
> >> <script src="${std.tg_js}/js/MochiKit.js"/>
> >>
> >> Alternatively, if you need mochi in all pages, you can set the config
> >> variable tg.mochikit_all to True so it gets automatically included in
> >> all pages.
> >>
> >> Another way would be to return the mochikit JSLink widget in the dict
> >> you return from your controller to the template engine:
> >>
> >> from turbogears.widgets import mochikit
> >>
> >> def controllermethod(....)
> >>    return dict(
> >>            foo = bar,
> >>            mochi = mochikit,
> >>    )
> >>
> >> This last trick takes advantage of the machinery TG widgets use to
> >> pull all their required JS and CSS links into the template, it's the
> >> preferred method IMO as if, by any chance, mochikit's js file path
> >> changes inside TG, you won't need to update your code.
> >>
> >>
> >> 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