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