Error: nevow_clientToServerEvent is not defined (Firefox JS Console)

Firstly, I love nevow, brilliant design, really just plain brilliant. Thanks in advance for any help with this problem. # PROBLEM The livepage/evil example failes with this error in the Firefox JS console # ERROR Error: nevow_clientToServerEvent is not defined # SYSTEM OS: Gentoo Linux Firefox version: 1.0.4 Nevow revision: 1595 # EXAMPLE CODE from nevow import rend, loaders, tags from nevow.liveevil import handler def greeter(client, nodeName): client.alert("Greetings. You clicked the %s node." % nodeName) # Any string arguments after the event handler function will be evaluated # as JavaScript in the context of the web browser and results passed to the # Python event handler handler = handler(greeter, 'node.name') class LivePage(rend.Page): docFactory = loaders.stan( tags.html[ tags.body[ tags.ol[ tags.li(onclick=handler, name="one")["One"], tags.li(onclick=handler, name="two")["Two"], tags.li(onclick=handler, name="three")["Three"] ] ] ]) Thanks

Quoting Michael M <m.milvo@gmail.com>: [snip]
class LivePage(rend.Page): docFactory = loaders.stan( tags.html[ tags.body[ tags.ol[ tags.li(onclick=handler, name="one")["One"], tags.li(onclick=handler, name="two")["Two"], tags.li(onclick=handler, name="three")["Three"] ] ] ])
I think this example hasn't been updated. You'd better look after the liveanimal.py example in the current branch. The example working should be like this (not tested): class MyLivePage(livepage.LivePage): docFactory = loaders.stan( tags.html[ tags.head[ tags.directive('liveid'), tags.directive('liveglue')], tags.body[ tags.ol[ tags.li(onclick=handler, name="one")["One"], tags.li(onclick=handler, name="two")["Two"], tags.li(onclick=handler, name="three")["Three"] ] ] ]) -- Thomas

On Jun 29, 2005, at 2:32 AM, Michael M wrote:
Firstly, I love nevow, brilliant design, really just plain brilliant. Thanks in advance for any help with this problem.
# PROBLEM The livepage/evil example failes with this error in the Firefox JS console
# ERROR Error: nevow_clientToServerEvent is not defined
Sorry, that example is way out of date. livepage is still under heavy development and has changed a lot in the last year or so. It has even changed a lot since the last release (0.4.1). If you would like to use livepage, I suggest you get a svn checkout of: svn://divmod.org/svn/Nevow/branches/dp/livepage-completion- notification-3 I have attached a simple example which works with this branch. I hope to have livepage stabilized by the 0.5 release (bugfixes notwithstanding). There is still quite a bit of work to be done before this will actually happen though. The reason nevow_clientToServerEvent was not defined in your tests is because the javascript which defines it was never included in the page. In the below example, you'll notice two render directives, one invoking "liveid" and one invoking "liveglue". The liveid is a fragment of javascript which embeds a unique id in every rendering of a LivePage. It changes every time the page is rendered. The liveglue is a fragment of javascript which never changes. It is separate from the liveid to allow you to have one global location for the liveglue javascript which every page references, to take advantage of browser caches. The other difference with this example is the ease of calling a server-side function from javascript. Once the liveglue javascript has been included in a page, there is a global "server" object which has a "handle" method. The javascript in the example below was written by hand, not generated automatically by the nevow page rendering process. This makes it easier to hook up client-side event handlers to server side methods. One final difference in the example below is that now server-side event handlers can return javascript which will be evaluated in the browser. Previously, you had to make calls on the ClientHandle object to send scripts to the browser (which you can still do if you need to). The new architecture instead renders the result of a server-side handler in a JavascriptContext. This means all the rendering advantages Nevow provides for HTML are also possible with JavaScript now (rendering generators, rendering multiple deferreds, much safer quoting, etc.) Hope all this helps. Donovan 

Does the current svn checkout handle XUL? I've tried playing with it with mixed results. I need to send updated values to client fields and later to bring em back. I've included slightly hacked versions of xul_nevow.py and xul_example.xul The label change works as expected but I'm not handling the text fields properly. Can someone please nudge or kick me in the right direction? Donovan Preston wrote:
On Jun 29, 2005, at 2:32 AM, Michael M wrote:
Firstly, I love nevow, brilliant design, really just plain brilliant. Thanks in advance for any help with this problem.
# PROBLEM The livepage/evil example failes with this error in the Firefox JS console
# ERROR Error: nevow_clientToServerEvent is not defined
Sorry, that example is way out of date. livepage is still under heavy development and has changed a lot in the last year or so. It has even changed a lot since the last release (0.4.1). If you would like to use livepage, I suggest you get a svn checkout of:
svn://divmod.org/svn/Nevow/branches/dp/livepage-completion-notification-3
I have attached a simple example which works with this branch.
I hope to have livepage stabilized by the 0.5 release (bugfixes notwithstanding). There is still quite a bit of work to be done before this will actually happen though.
The reason nevow_clientToServerEvent was not defined in your tests is because the javascript which defines it was never included in the page. In the below example, you'll notice two render directives, one invoking "liveid" and one invoking "liveglue". The liveid is a fragment of javascript which embeds a unique id in every rendering of a LivePage. It changes every time the page is rendered. The liveglue is a fragment of javascript which never changes. It is separate from the liveid to allow you to have one global location for the liveglue javascript which every page references, to take advantage of browser caches.
The other difference with this example is the ease of calling a server-side function from javascript. Once the liveglue javascript has been included in a page, there is a global "server" object which has a "handle" method. The javascript in the example below was written by hand, not generated automatically by the nevow page rendering process. This makes it easier to hook up client-side event handlers to server side methods.
One final difference in the example below is that now server-side event handlers can return javascript which will be evaluated in the browser. Previously, you had to make calls on the ClientHandle object to send scripts to the browser (which you can still do if you need to). The new architecture instead renders the result of a server-side handler in a JavascriptContext. This means all the rendering advantages Nevow provides for HTML are also possible with JavaScript now (rendering generators, rendering multiple deferreds, much safer quoting, etc.)
Hope all this helps. Donovan
------------------------------------------------------------------------
------------------------------------------------------------------------
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

On Jun 29, 2005, at 8:54 PM, Uwe (Peter) Feldtmann wrote:
Does the current svn checkout handle XUL?
Seems to :-)
I've tried playing with it with mixed results.
I need to send updated values to client fields and later to bring em back. I've included slightly hacked versions of xul_nevow.py and xul_example.xul The label change works as expected but I'm not handling the text fields properly.
Can someone please nudge or kick me in the right direction?
Well, you had a simple problem in your example file. You defined a function at the module level named onCommand, which you presumably wanted to be called at some point, but you never called it. I have attached an updated example which eschews the function entirely and puts all the logic in the handle_onCommand method. Note that it is still possible to program in the old style by doing IClientHandle(ctx) to get the client instance and repeatedly calling .send on it, but instead I have changed your example to return a list of javascript to send to the browser. Nevow now uses the normal rendering machinery to render javascript results from handlers and javascript which is pushed to the browser, so this is a natural way to express it. Note that currently, you are required to include a newline or semicolon to delimit your statements; like nevow's html rendering, the javascript rendering does not currently insert newlines anywhere. I have suspected for a while that it would be safe to insert newlines in between list elements while rendering in a JavascriptContext, but I haven't tested this theory yet. If it is possible to insert these newlines automatically then the livepage.eol will no longer be necessary, which would be very nice. Note that: livepage.eol = livepage.js('\n') ## A newline character Here is your working example (the XUL file didn't change at all):

Thanks, it did help. I have attached a stan version for anybody else that comes across this thread. I did notice when upgrading to the svn branch you recommended (svn://divmod.org/svn/Nevow/branches/dp/livepage-completion-notification-3), that addSlash seems to be required on root objects but not on children. Where do I look to find information on what addSlash does, ( I know it is probably obvious but still I haven't seen it in my wanderings yet :). Last questions, 1.) Is this the main branch for livepage development? 2.) is this branch likely to change before 0.5? 3.) If so how can I be notified, or do I just watch this list? 4.) Is the api for livepage likely to change much or is it just in need of more general development? Thanks in advance. <dribble_warning> I looked at nevow when it was version 0.1 and couldn't make much sense of it so I tried apache + mod_python and then tried to develop my own pure python web application setup. I ran into problems, then thought I would checkout nevow again. When I looked at it I realised that it solved all the problems I was having in a brilliant way. There are very few pieces of software that have made me as excited as nevow has. I guess I had to try to solve the problems first before I appreciated what you guys already solved. So thanks and keep up the brilliant work. </dribble_warning>

Michael M wrote:
Thanks, it did help. I have attached a stan version for anybody else that comes across this thread.
I did notice when upgrading to the svn branch you recommended (svn://divmod.org/svn/Nevow/branches/dp/livepage-completion-notification-3), that addSlash seems to be required on root objects but not on children. Where do I look to find information on what addSlash does, ( I know it is probably obvious but still I haven't seen it in my wanderings yet :).
addSlash is semi-documented in the .txt docs dp wrote, see docs/txt/nevow-traversal.txt. Basically, addSlash=True forces a redirect when a resource is requested without the trailing slash. addSlash serves two main purposes: * Relative URLs become manageable. * Directory-like resources can process the trailing '' segment and choose to render a listing or a default resource such as index.html. Browsers append a slash when requesting the root resource of a site so it makes sense for root resources to be addSlash=True.
Last questions, 1.) Is this the main branch for livepage development?
Yes.
2.) is this branch likely to change before 0.5?
Yes, but probably not too much ... although dp might have different ideas about that.
3.) If so how can I be notified, or do I just watch this list?
Subsribe to the nevow commits list. http://divmod.org/users/mailman.twistd/listinfo/nevow-commits
4.) Is the api for livepage likely to change much or is it just in need of more general development?
I'll let dp answer this more but I think that branch is about finalising the livepage API. The old API had a few problems, especially around error handling.
Thanks in advance.
<dribble_warning> I looked at nevow when it was version 0.1 and couldn't make much sense of it so I tried apache + mod_python and then tried to develop my own pure python web application setup. I ran into problems, then thought I would checkout nevow again. When I looked at it I realised that it solved all the problems I was having in a brilliant way. There are very few pieces of software that have made me as excited as nevow has. I guess I had to try to solve the problems first before I appreciated what you guys already solved. So thanks and keep up the brilliant work. </dribble_warning>
Welcome aboard :) Cheers, Matt -- __ / \__ Matt Goodall, Pollenation Internet Ltd \__/ \ w: http://www.pollenation.net __/ \__/ e: matt@pollenation.net / \__/ \ t: +44 (0)113 2252500 \__/ \__/ / \ Any views expressed are my own and do not necessarily \__/ reflect the views of my employer.

On Jul 1, 2005, at 2:39 AM, Matt Goodall wrote:
Michael M wrote:
Thanks, it did help. I have attached a stan version for anybody else that comes across this thread. I did notice when upgrading to the svn branch you recommended (svn://divmod.org/svn/Nevow/branches/dp/livepage-completion- notification-3), that addSlash seems to be required on root objects but not on children. Where do I look to find information on what addSlash does, ( I know it is probably obvious but still I haven't seen it in my wanderings yet :).
addSlash is semi-documented in the .txt docs dp wrote, see docs/txt/ nevow-traversal.txt.
Basically, addSlash=True forces a redirect when a resource is requested without the trailing slash. addSlash serves two main purposes:
* Relative URLs become manageable. * Directory-like resources can process the trailing '' segment and choose to render a listing or a default resource such as index.html.
Browsers append a slash when requesting the root resource of a site so it makes sense for root resources to be addSlash=True.
Should we set addSlash = True in NevowSite.__init__ on the root resource that is passed? It's pretty confusing to try to build a tiny site and get a 404 on the root of it because you forgot to specify addSlash.
Last questions, 1.) Is this the main branch for livepage development?
Yes.
2.) is this branch likely to change before 0.5?
Yes, but probably not too much ... although dp might have different ideas about that.
The dispatch_ stuff I mentioned in a previous email will be completed before 0.5. I am currently thinking of calling it frag_* instead of dispatch_*. Anyone who has a problem with this, speak up now :-) Also, the livepage-completion-notification-3 branch will have to be merged with trunk and branched again ("merged forward" as we call it at Divmod) to resolve logical conflicts introduced by mg into trunk with string quoting in various contexts. When I do this I will send a message to this list, and the new branch will be called livepage- completion-notification-4. This branch will be fairly short lived, and I hope to merge it into trunk as soon as I can. (By the end of next week maybe?)
3.) If so how can I be notified, or do I just watch this list?
Subsribe to the nevow commits list.
http://divmod.org/users/mailman.twistd/listinfo/nevow-commits
4.) Is the api for livepage likely to change much or is it just in need of more general development?
I'll let dp answer this more but I think that branch is about finalising the livepage API. The old API had a few problems, especially around error handling.
This branch is an attempt to finalize the API and fix some problems with the earlier API. So far all indications are good that there aren't any problems with the new API. Barring some unforeseen huge problems, I don't think the livepage API will be changing any more. This means if anybody wants to propose radical changes to the way things work, now is the time to do it (or forever hold your peace, etc) Thanks for trying it out. I need all the feedback I can get. Donovan

Should we set addSlash = True in NevowSite.__init__ on the root resource that is passed? It's pretty confusing to try to build a tiny site and get a 404 on the root of it because you forgot to specify addSlash.
Yeah, that would be great, it took me a while of looking at old and new examples to work out what had changed, i,e what I was missing. Thanks for you help.
participants (5)
-
Donovan Preston
-
Matt Goodall
-
Michael M
-
Thomas HERVE
-
Uwe (Peter) Feldtmann