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

Jean-Paul Calderone exarkun at divmod.com
Tue May 29 19:25:23 EDT 2007

On Wed, 30 May 2007 01:44:07 +0300, kgi <iacovou at gmail.com> wrote:
>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).

This is like trying to call an unbound method in Python.  What you really
want to be doing is calling chain on an /instance/ of XCall.B, not on the
class object itself.

Also, I'd recommend not clobbering XCall.A and XCall.B with your class
objects, since those are set up to be module objects because they each
have a corresponding .js file.  Athena's module system tries to mimick
many aspects of Python's - in this case, XCall corresponds to a package,
XCall.A and XCall.B are modules in that package, and you want to be
defining things like XCall.A.Foo and XCall.B.Bar as attributes of those


More information about the Twisted-web mailing list