rem: /* The response's content is a JSON-encoded 4-array of [Response-Id, * Request-Id, Content-Type, Content].  If this is a response to a * previous request, responseId will not be null.  If this is a * server-initiated request, requestId will not be null. 
add: /* The response's content is a JSON-encoded 4-array of * [Response-Id, Request-Id, Content-Type, [success, result]].  If * this is a response to a previous request, responseId will not * be null.  If this is a server-initiated request, requestId will * not be null. 
context: Nevow.Athena.XMLHttpRequestReady = function (req) {    Nevow.Athena.debug('A request is completed: ' + req.responseText);    /* The response's content is a JSON-encoded 4-array of [Response-Id,     * Request-Id, Content-Type, Content].  If this is a response to a     * previous request, responseId will not be null.  If this is a     * server-initiated request, requestId will not be null.     */    if (req.responseText == '') {        /* Server timed out the transport, just re-request */        Nevow.Athena.debug('Empty server message, reconnecting');        if (Nevow.Athena.outstandingTransports == 0) {            Nevow.Athena.debug('No outstanding transports, sending no-op');            Nevow.Athena.sendNoOp();        }        return;    }    Nevow.Athena.debug('evaluating json in responseText');    var responseParts = MochiKit.Base.evalJSON(req.responseText);    Nevow.Athena.debug('evaluated it');    Nevow.Athena.failureCount = 0;    var responseId = responseParts[0];    var requestId = responseParts[1];    if (requestId != null) {        Nevow.Athena.debug('Got a response to a request');        var contentType = responseParts[2];        var contentBody = responseParts[3];        var d = Nevow.Athena.remoteCalls[requestId];        var handler = Nevow.Athena.responseDispatchTable[contentType];        delete Nevow.Athena.remoteCalls[requestId];        if (handler != null) {            handler(d, contentBody);        } else {            Nevow.Athena.debug("Unknown content-type: " + contentType);            d.errback(new Error("Unhandled content type: " + contentType));        }    } else if (responseId != null) {        Nevow.Athena.debug('Server initiated request');        var contentBody = responseParts[2];        var objectId = contentBody[0];        var methodName = contentBody[1];        var methodArgs = contentBody[2];        /*        var resultD = Nevow.Athena.localObjectTable[objectId].dispatch(methodName, methodArgs);        resultD.addCallbacks(Nevow.Athena.respondToRequest        */        Nevow.Athena.debug('Invoking ' + new String(methodName) + ' with arguments ' + new String(methodArgs));        var result = eval(methodName).apply(null, methodArgs);        Nevow.Athena.debug('Invoked it');        var isDeferred = false;        if (result == undefined) {            Nevow.Athena.debug('it was undefined');            result = null;        } else {            /* if it quacks like a duck ...               this sucks!!!  */            isDeferred = (typeof(result.addCallback) != 'undefined' &&                          typeof(result.addErrback) != 'undefined');        }        Nevow.Athena.debug('Is it a deferred? ' + new String(isDeferred));        if (isDeferred) {            Nevow.Athena.debug('It is a deferred, adding a callback');            result.addCallback(function(result) {                Nevow.Athena.respondToRemote(responseId, result);            });        } else {            Nevow.Athena.debug('Responding synchronously to remote request with ID ' + new String(responseId));            Nevow.Athena.respondToRemote(responseId, result);        }    }    /* Client code has had a chance to run now, in response to     * receiving the result.  If it issued a new request, we've got an     * output channel already.  If it didn't, though, we might not     * have one.  In that case, issue a no-op to the server so it can     * send us things if it needs to. */    if (Nevow.Athena.outstandingTransports == 0) {        Nevow.Athena.sendNoOp();    }};
meta: 1565	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/1565/99cc5fa4def1a6baac808331d5a13fcb92370029/athena.js/clean/nevow/athena.js