[Twisted-web] athena and widget.nodeById

Phil Mayers p.mayers at imperial.ac.uk
Fri Aug 3 06:27:45 EDT 2007


I've got this:

class logwatch(athena.LiveFragment):
  jsClass = u"app.logwatch"

  docFactory = loaders.stan(
    T.div(render=T.directive('liveFragment'))[
      T.div(id='content'),
    ])

  def msg(self, m):
    return self.callRemote('msg', m)

...and in app.js

app.logwatch = Nevow.Athena.Widget.subclass('app.logwatch');
app.logwatch.methods(
  function msg(self, m) {
    // MochiKit is included...
    appendChildNodes(
      self.nodeById('content'),
      P(null, m)
    );
  })

This fails for some reason - I think because the HTML the page generates
looks like this:

<div id="athena:1" xmlns:athena="http://divmod.org/ns/athena/0.7"
athena:class="app.logwatch">
 logs
 <div id="athenaid:1-athenaid:1-content"/>
</div>

...node the athena node id prefixs the child IDs twice?

Also, the exception this code generates under Firefox (2.0.0.4) also
breaks the javascript-python exception bridge code:

   File "/usr/lib64/python2.5/site-packages/twisted/internet/defer.py",
line 107, in maybeDeferred
     result = f(*args, **kw)
   File "/usr/lib/python2.5/site-packages/nevow/athena.py", line 434, in
renderHTTP
     response = self.messageDeliverer.basketCaseReceived(ctx,
messageData)
   File "/usr/lib/python2.5/site-packages/nevow/athena.py", line 638, in
basketCaseReceived
     self.livePage.liveTransportMessageReceived(ctx, msg)
   File "/usr/lib/python2.5/site-packages/nevow/athena.py", line 886, in
liveTransportMessageReceived
     method(ctx, *args)
   File "/usr/lib/python2.5/site-packages/nevow/athena.py", line 929, in
action_respond
     callDeferred.errback(getJSFailure(result, self.jsModules.mapping))
   File "/usr/lib/python2.5/site-packages/nevow/athena.py", line 403, in
getJSFailure
     text = '%s: %s' % (exc[u'name'], exc[u'message'])
 exceptions.KeyError: u'name'

Ideas?




More information about the Twisted-web mailing list