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

kgi iacovou at gmail.com
Tue May 29 18:44:07 EDT 2007

Hi all.

I'm doing a lot of Athena stuff at the moment. Calls from client->server and 
server-> client (which is virtually 100% of the calls) are working 
wonderfully. However, I'm having difficulty getting one Javascript module to 
call directly onto another Javascript module (that is, client->client) in a 
way that I would expect, and I think it's something in the package/module 
system Athena uses that I haven't yet grokked.

I've attached a minimal test case. Since it actually has a directory 
structure, I've tar-gzipped it; sorry for the additional inconvenience. 
Directions are in the README file. The only requirement is that you modify 
PYTHONPATH before twistd-ing the tac file (actually, it's a .py file, but it 
should be a .tac file).

Briefly, the problem is this: I've got two Javascript modules associated with 
LiveElements; in the example these are XCall.A and XCall.B. XCall.A knows 
about XCall.B through an import "statement"; that is, it has a line:

    // import XCall.B

It tries to call a method on XCall.B (XCall.B.chain()), but it can't see this 
method and throws an exception (which is caught by Nevow).

Examining the Javascript objects through Firebug shows that XCall.B doesn't 
have any of the methods passed to its methods() method in the object 
top-level namespace; instead, these are all available in the "prototype" 

In other words, I can call XCall.B.prototype.chain(), but not XCall.B.chain().

Now, I know that the "prototype" attribute is the kooky way that Javascript 
implements some of its OO-ness, but all the Nevow code seems not to do it 
this way: it just imports and uses directly:

    // import Foo.Bar

so I'm confused as to why I can't do the same thing myself. 

I'm running Python 2.5, Twisted 2.5.0, and have the same problem on both Nevow 
0.9.18 and on trunk head.

Can anyone spot what I'm doing wrong?



-------------- next part --------------
A non-text attachment was scrubbed...
Name: xcall.tar.gz
Type: application/x-tgz
Size: 1622 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-web/attachments/20070530/918cf08d/xcall.tar.bin

More information about the Twisted-web mailing list