[Developers] mjt and the freebase api changes

Will Moffat will at hamstersoup.com
Sat Jun 16 14:18:26 UTC 2007


Dear Freebase MJT users,

On 6/16/07, Nick Thompson <nix at metaweb.com> wrote:
> i've had reports that http://mjtemplate.org isn't up to date with the
> recent freebase api change

If you are getting MJT Freebase withdrawal symptoms this weekend,
here's the simple fix:

In mjt.MqlReadRequest.prototype.response_handler

Make this change:
          //if (sr.status == '/mql/status/ok') {   //OLD
	    if (sr.code   == '/api/status/ok') {   //NEW

Or just override the whole function by copying the code below into in
your own .js file.
regards,
--Will


//
// handle a query response.
//   do most of the work for all json callback handlers
//
mjt.MqlReadRequest.prototype.response_handler = function(o) {

    if (typeof(o) == 'string' && o == mjt._timeout_token) {
        mjt.task_timeout(this);
    } else {
        this.state = 'ready';
    }

    // split result and notify all dependents
    for (var sqk in this.subqueries) {
        var sq = this.subqueries[sqk];

        if (typeof(o) == 'string' && o == mjt._timeout_token) {
            sq.state = 'error';
            sq._error_type = '/user/mjt/messages/script_timeout';
            sq.messages = [{
                type: '/user/mjt/messages/script_timeout',
                text: "browser could not contact the server",
                level: 'error'
            }];
        } else {
            var sr = o[sqk];

            if ('cursor' in sr)
                sq.next_cursor = sr.cursor;

            if ('messages' in sr)
                sq.messages = sr.messages;

          //if (sr.status == '/mql/status/ok') {   //OLD
	    if (sr.code   == '/api/status/ok') {   //NEW
                if (sr.result == null) {
                    sq.state = 'error';
                    sq.messages = [{
                        type: '/user/mjt/messages/empty_result',
                        text: "no results found",
                        level: 'error'
                    }];
                } else {
                    sq.result = sr.result;
                    sq.state = 'ready';
                }
            } else {
                sq.state = 'error';
                sq._error_type = sr.status;
                mjt.debug && mjt.spew('mqlread failed', sq);
            }
        }

        //if (sq.state == 'ready' && sq.result == null)
        //    sq.state = 'nomatch';
        mjt.notify(sq);
    }
};


More information about the Developers mailing list