On May 2, 2005, at 5:47 PM, Peter Hunt wrote:

Hello everyone,

A long time ago (before the advent of IronPython), I wrote a small Python module that compiled a python file to a JScript.NET file and compiled it. Seeing as JScript and _javascript_ are very similar, I bet this could be very helpful. See http://subway.python-hosting.com/attachment/wiki/Py2Js/pyc.2.py for the code.

This is awesome, thank you for posting the link. I had planned on doing something similar to this for a long time, for both _javascript_ and ActionScript (flash bytecode instead of text script). However LivePage is just a hobby for me, so I never found time.

I envision a world where we can write something like:
<input type="button" />

And it will do a server-side RPC to the onButtonClick() method, which could do something like this:
def onButtonClick(ctx):
    ctx.document.writeln("Button clicked")

ctx would serve as a magical proxy for method calls back to the client. This would allow seamless integration of _javascript_ and Python without even writing a line of JS. What do you think?

Yep, this is almost exactly what LivePage looks like.

def onButtonClick(client):
    client.sendScript("alert('hello world')")


class Foo(LivePage):
    def render_clickable(self, ctx, _):
        return ctx.tag(>

    docFactory = loaders.htmlstr('<input type="button" nevow:render="clickable" />')

I think I like your proposed syntax, with a "server" object in _javascript_; I'll mess around with adding support for something like it to LivePage. I'm not sure I like the magical proxy server-side interface too much. nevow.livepage.ClientHandle has a nice API which provides convenient methods for mutating the client side dom:

set - replace an old node's contents with some new contents
append - append a new node as a child of an old one
prepend - prepend a new node as the first child of an old one
alert - show the user an alert
call - call a client side _javascript_ function with some arguments
sendScript - send arbitrary _javascript_ for execution

Donovan

_______________________________________________
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com

Reply via email to