[Twisted-web] Adding athena.LiveElement to an already-rendered LivePage

Michał Pasternak michal.dtz at gmail.com
Sun Nov 9 15:09:41 EST 2008


Jean-Paul Calderone pisze:
> On Sun, 09 Nov 2008 13:28:26 +0100, Michał Pasternak 
> <michal.dtz at gmail.com> wrote:
>> Hi,
>>
>> I want to be able to add athena.LiveElement to an already rendered 
>> LivePage. Quick Googling revealed this blog entry:
>>
>>    
>> http://techblog.ironfroggy.com/2006/01/nevow-post-render-injection- 
>> of.html
>>
>> I'd like to know, if there are any other, simpler ways to do that - 
>> or, maybe, is there a preferred method to do that in the API already?
>
> See Nevow.Athena.Widget.addChildWidgetFromWidgetInfo.
This method will not add the markup automatically. Am I right?

I want to append incoming LiveFragments to the page.

Right now, I am doing something like this on the client:

// import Divmod.Runtime

What.Ever = Nevow.Athena.Widget.subclass('What.Ever');
What.Ever.methods =(

  function foo(self) {
    d = self.callRemote('getLiveFragment');

    d.addCallback(

      function liveFragmentReceived(lf) {

        d2 = self.addChildWidgetFromWidgetInfo(lf);

        d2.addCallback(

          function added(res) {

            d = Divmod.Runtime.theRuntime.parseXHTMLString(
              lf.markup).documentElement;

            self.nodeById('lastNode').appendChild(d);

          });

      });

  });

Is this the official way of doing that, or am I missing something?

-- 
m




More information about the Twisted-web mailing list