MochiKit 1.4 + Turbogears

8 views
Skip to first unread message

Kevin H

unread,
Feb 7, 2007, 11:20:58 PM2/7/07
to TurboGears
Has anyone tried using the development release of MochiKit in their TG
apps?

Is it useable?

If so, how would you modify TG to use it? Is it just a matter of
replacing the appropriate files, or is there more to it?

Kevin Horn

Arnar Birgisson

unread,
Feb 8, 2007, 3:38:48 AM2/8/07
to turbo...@googlegroups.com
Hi Kevin,

On 2/8/07, Kevin H <kevin...@gmail.com> wrote:
>
> Has anyone tried using the development release of MochiKit in their TG
> apps?
>
> Is it useable?

Yes, I use it all the time (literally). It's very usable and the trunk
right now is stable enough for my applications (even for production).
I think the 1.4 release is close though.

> If so, how would you modify TG to use it? Is it just a matter of
> replacing the appropriate files, or is there more to it?

For me it works very well just to include the newest MochiKit in the
static dir and link to it from there. Then again I'm not really using
any widgets so that might be the reason I haven't had any problems.

Arnar

iain duncan

unread,
Feb 8, 2007, 3:51:43 AM2/8/07
to turbo...@googlegroups.com

> For me it works very well just to include the newest MochiKit in the
> static dir and link to it from there. Then again I'm not really using
> any widgets so that might be the reason I haven't had any problems.

I haven't had problems yet using mochikit 1.4 with widgets. But I
certainly haven't tested all the options!

Iain


Christopher Arndt

unread,
Feb 8, 2007, 4:21:18 AM2/8/07
to turbo...@googlegroups.com
Kevin H schrieb:

> Has anyone tried using the development release of MochiKit in their TG
> apps?

Yes.

> Is it useable?

I haven't tested it thoroughly but had no problems so far. I use it, because
XmlHttp POST requests are a lot easier.

> If so, how would you modify TG to use it? Is it just a matter of
> replacing the appropriate files, or is there more to it?

I have built my own mini-widget as a replacement for the standard one:

---> myproject/widgets/jslibs/__init__.py <---
__all__ = [
'mochikit'
]

import pkg_resources
from turbogears.widgets import JSLink, register_static_directory

js_dir = pkg_resources.resource_filename("myproject.widgets.jslibs",
"static")
register_static_directory("jslibs", js_dir)

mochikit = JSLink("jslibs", "javascript/MochiKit.js")
---> end <---

then put MochiKit.js 1.4 in myproject/widgets/jslibs/static/javascript

and use it in your application by e.g. setting tg_include_widgets to
['myproject.widgets.jslibs.mochikit']

This way you always have MochiKit 1.4 distributed with your app and don't rely
on a patched TG installation.


HTH, Chris

Kevin Horn

unread,
Feb 8, 2007, 12:22:15 PM2/8/07
to turbo...@googlegroups.com
Thanks, Chris!

I don't think I've seen a better explanation of how to set up a custom javascript include directory anywhere.

My own past solutions have been ... hmmm ... much less elegant.  The bit about "tg_include_widgets" is especially enlightening, as I had completely forgotten that that existed.

Very useful! Thanks again!

Kevin Horn

Arnar Birgisson

unread,
Feb 8, 2007, 12:43:50 PM2/8/07
to turbo...@googlegroups.com
On 2/8/07, Kevin Horn <kevin...@gmail.com> wrote:
> Thanks, Chris!
>
> I don't think I've seen a better explanation of how to set up a custom
> javascript include directory anywhere.

I agree, I gave Crhis' post a gold star in my gmail box :o)

Maybe this should be posted on the wiki?

Arnar

Christopher Arndt

unread,
Feb 8, 2007, 1:12:07 PM2/8/07
to turbo...@googlegroups.com
Kevin Horn schrieb:
> Very useful! Thanks again!

You're welcome.

I should maybe add, that of course you need an (possibly empty) '__init__.py'
file in 'myproject/widgets' as well.

Chris

Kevin Horn

unread,
Feb 8, 2007, 2:20:27 PM2/8/07
to turbo...@googlegroups.com
On 2/8/07, Arnar Birgisson <arn...@gmail.com> wrote:
I gave Crhis' post a gold star in my gmail box :o)

Me too :)

Maybe this should be posted on the wiki?

It probably should.
 
Kevin Horn
Reply all
Reply to author
Forward
0 new messages