[Twisted-Python] Woven LivePage sendScript works with some scripts but not others

Tim Andrews tim.andrews at adpro.com.au
Fri Jul 18 00:25:19 EDT 2003

> > I'm trying to use LivePage to send some script to a web page.
> >
> > All works well if the script is as per the manual example, ie
> > sendScript("alert('Hello world!')")
> > will pop up a window as expected.
> >
> > However, if i try a script like "document.all.fred.innerHTML='FRED'" I
> > get
> > an error on the page "Error: document.all.fred is null or not an
> > object". I
> > know the script is okay because if it is on the on the page it will
> > work.
> >
> > Any clues?
> This is *probably* because, with the version of LivePage you are
> currently using, the JavaScript is evaluated within the context of the
> Output IFrame. I'm not a regular in-browser javascript expert, but
> something like top.document.all.fred or parent.document.all.fred might
> work better for you.

Both of these work, thankyou.

> By the way, if you are trying to do your own innerHTML setting, don't.

I was just experimenting here as it more familiar territory.

> Woven LivePage includes a cross-browser abstraction of this sort of
> in-browser DOM mutation. Just write your Widgets in a way that they
> will always render themselves the way you want them to based on the
> Model data and the state of the session. (For example, you could set
> session.color = 'blue' and it would be different from someone else who
> has session.color = 'green')
> Then, use one of the MVC notification APIs to cause Woven to re-render
> your Widget and send the appropriate, abstract JavaScript to the
> browser:
> someWidgetReference. modelChanged({'request': request})
> or
> someModelReference.notify({'request': request})

Could you give me a few more hints here please.  I'm still trying to get my
head around Chapter 7 of "The Twisted Documentation".  Is there anything
else to read in conjunction or should I start wading through the code?



> Why the hideous dictionary-with-the-request-in-it? Ancient historical
> reasons which are entirely irrelevant now. I will change it to simply
> take the request asap, but for now, just do that :-)
> dp
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list