[Twisted-web] Athena & browser 2-connection limit

Werner Thie wthie at thiengineering.ch
Tue Oct 7 13:18:23 EDT 2008


May I pick up this particular problem and its proposed solution up again:

In

Nevow.Athena.bootstrap = function (pageClassName, clientID) {
     var self = this;
     var pageClass = Divmod.namedAny(pageClassName);
     self.page = pageClass(clientID, Nevow.Athena._createMessageDelivery);
     self.page.bindEvents(window);

     Divmod.Runtime.theRuntime.addLoadEvent(function transportStartup() {
             Divmod.debug("transport", "starting up");
             self.page.deliveryChannel.start();
             Divmod.debug("transport", "started up");

             Divmod.debug("widget", "Instantiating live widgets");
             Nevow.Athena.Widget._pageLoaded = true;
             Nevow.Athena.Widget._instantiateWidgets();
             Divmod.debug("widget", "Finished instantiating live widgets");
						window.document.body.onbeforeunload = window.onbeforeunload;
         });
};

window.onbeforeunload gets assigned a callstack with bindEvents(window). 
Odd though that the debugger shows the property still as null in IE when 
stopping after bindEvents. The post on bustedmug
http://bustedmug.blogspot.com/2007/01/onbeforeunload-ie7-assigning-event.html
and some debugging revealed that at least under IE7 
window.onbeforeunload cannot be assigned to until window.document.body 
exists.

Adding the really odd assigment

window.document.body.onbeforeunload = window.onbeforeunload;

in the function transportStartup sets up everything perfectly for the IE 
browsers, does not disturb the other browsers tested, triggers the 
onbeforeunload reliably and refresh ad lib is possible with all tested 
browsers given down below, the lockups on the IE family are gone.

Tested calculator example with
Firefox 2.0.0.14
Firefox 3.03
Chrome Build 2200
Safari 3.1.2
Opera 9.24
IE6.0.2800
IE7.0.5730
IE8.0.6001 (Beta)

How shall I proceed?
Was there a ticket opened by Harald Blåtand?

Thanks, Werner

Harald Blåtand wrote:
> 
> 
> On Tue, Sep 16, 2008 at 4:39 PM, Werner Thie <wthie at thiengineering.ch> 
> wrote:
> 
>     There are some post revolving around onbeforeunload/IE7 and a quick
>     debugging session shows that no code is ever executed for
>     onbeforeunload with IE.
> 
>          
> 
> I came up with the following some months ago. Since then, we're not 
> seeing the problem on IE6 or 7. Would be interested in hearing whether 
> it works for you. (Would have entered it as a Divmod ticket, but can't 
> seem to find a way to create one, nor to create an account...)
>  
> Harald
>  
> ------------------------------------------------------------------------------------------------------------------------
> Here's what I've changed in the 0.9.31 JS code:
>  
> ------------------ Nevow/Athena/__init__.js (2 additions) 
> --------------------------
> Nevow.Athena.Widget._initialize = function() {
>     Divmod.debug("widget", "Instantiating live widgets");
>     Nevow.Athena.Widget._pageLoaded = true;
>     // With the next line, sendCloseMessage will get called in IE. // Harald
>     Divmod.Base.addUnLoadEvent(Nevow.Athena.page.deliveryChannel); // Harald
>     Nevow.Athena.Widget._instantiateWidgets();
>     Divmod.debug("widget", "Finished instantiating live widgets");
> };
> Nevow.Athena.bootstrap = function (pageClassName, clientID) {
>     var self = this;
>     var pageClass = Divmod.namedAny(pageClassName);
>     self.page = pageClass(clientID, Nevow.Athena._createMessageDelivery);
>     Nevow.Athena.page = self.page;                                // Harald
>     self.page.bindEvents(window);
>     .....
>  
> ------------------ Divmod/Base.js (1 added function at the end) 
> --------------------------
> Divmod.Base.addUnLoadEvent = function(channel) {
>     /***
>         Harald's desperate try to get IE page refresh to work...
>     ***/
>     window.attachEvent("onunload", function (e) 
> {channel.sendCloseMessage();});
> };
> Divmod.Base.jsonRegistry = Divmod.Base.AdapterRegistry();
>  
> I'm not used to this coding style, so it's a bit of trial & error. 
> Anyway, before, sendCloseMessage would _not_ be called; now it is, and I 
> can refresh ad lib on IE 6.and 7.
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web



More information about the Twisted-web mailing list