[Twisted-web] Trouble chaining Javascript module calls in Athena (example code attached).

L. Daniel Burr ldanielburr at mac.com
Wed May 30 11:16:27 EDT 2007

Pardon me for jumping in here, but I think you're making this too hard.

On Wed, 30 May 2007 09:53:11 -0500, kgi <iacovou at gmail.com> wrote:

> Yep, I see the attributes for traversing along the hierarchy. Unless I've
> misunderstood, in order for a widget's Javascript to be able to call  
> another
> widget's Javascript, it has to do something like:
>   self.widgetParent.widgetParent.widgetParent ...
> childWidgets[0].childWidgets[1].doStuff()

You can certainly do that, but there are plenty of other means of
accomplishing this aim.

For example, a widget has __init__() and nodeInserted() methods that
you can override.  If you want your widget instances accessible by
some name known to you, then just do:

self.widgetParent.someNameILikeToUseForThisParticularWidget = self;

Better still, use a client-side event dispatching mechanism, and
just let interested widget subscribe to a given "channel":

MyDispatcher = {
     _subscribers: [],
     publish: function(channel, message){
     subscribe: function(channel){

Hopefully, this gives you some easier options to consider.

L. Daniel Burr
ldanielburr at mac.com

More information about the Twisted-web mailing list