def ajax_import(url, namespace=None, names=None):
    setCompilerOptions("noDebug")
    if __imported__.has_key(url):
        module = __imported__[url]
    else:
        req = load(url, None, None, False)
        module = None
        name_getter = []
        if names is None:
            names = []
        for name in names:
            name_getter.append("$pyjs$moduleObject['%s'] = %s;" % (name, name))

        script = """(function ( ) {
$pyjs$moduleObject={};
%s;
%s
return $pyjs$moduleObject;
})();""" % (req.responseText, "\n".join(name_getter))
        try:
            module = eval(script)
        except:
            e = sys.exc_info()
            raise AjaxError("Error in %s: %s" % (url, e.message))
        __imported__[url] = module
    inject(module, namespace, names)
Beispiel #2
0
def ajax_import(url, namespace=None, names=None):
    setCompilerOptions("noDebug")
    if __imported__.has_key(url):
        module = __imported__[url]
    else:
        req = load(url, None, None, False)
        module = None
        name_getter = []
        if names is None:
            names = []
        for name in names:
            name_getter.append("$pyjs$moduleObject['%s'] = %s;" % (name, name))

        script = """(function ( ) {
$pyjs$moduleObject={};
%s;
%s
return $pyjs$moduleObject;
})();""" % (req.responseText, "\n".join(name_getter))
        try:
            module = eval(script)
        except:
            e = sys.exc_info()
            raise AjaxError("Error in %s: %s" % (url, e.message))
        __imported__[url] = module
    inject(module, namespace, names)
Beispiel #3
0
def ajax_eval(url, on_load_fn, async):
    setCompilerOptions("noDebug")
    def onready(evnt, req):
        str = req.responseText
        activate_javascript(str)
        if not on_load_fn is None:
            on_load_fn()

    load(url, None, onready, async)
Beispiel #4
0
def ajax_eval(url, on_load_fn, async):
    setCompilerOptions("noDebug")

    def onready(evnt, req):
        str = req.responseText
        activate_javascript(str)
        if not on_load_fn is None:
            on_load_fn()

    load(url, None, onready, async)
Beispiel #5
0
#
# Warning: this is an alpha module and might be removed/renamed in
# later pyjamas versions
#
from __pyjamas__ import wnd, doc, JS, setCompilerOptions
from __javascript__ import ActiveXObject, XMLHttpRequest
from pyjamas import DOM
from __pyjamas__ import debugger
import sys

setCompilerOptions("noSourceTracking", "noLineTracking", "noStoreSource")

class AjaxError(RuntimeError):
    pass

def createHttpRequest():
    if JS("""typeof $wnd['XMLHttpRequest'] != 'undefined'"""):
        # IE7+, Mozilla, Safari, ...
       return JS("""new XMLHttpRequest()""")

    # Check for IE6/ActiveX
    try:
        res = JS("""new ActiveXObject("Msxml2['XMLHTTP']")""")
        return res
    except:
        pass
    return None

#
#  load(url)
#
Beispiel #6
0
#
# Warning: this is an alpha module and might be removed/renamed in
# later pyjamas versions
#
from __pyjamas__ import wnd, doc, JS, setCompilerOptions
from __javascript__ import ActiveXObject, XMLHttpRequest
from pyjamas import DOM
from __pyjamas__ import debugger
import sys

setCompilerOptions("noSourceTracking", "noLineTracking", "noStoreSource")


class AjaxError(RuntimeError):
    pass


def createHttpRequest():
    if JS("""typeof $wnd.XMLHttpRequest != 'undefined'"""):
        # IE7+, Mozilla, Safari, ...
        return JS("""new XMLHttpRequest()""")

    # Check for IE6/ActiveX
    try:
        res = JS("""new ActiveXObject("Msxml2.XMLHTTP")""")
        return res
    except:
        pass
    return None

Beispiel #7
0
from __pyjamas__ import INT, JS, setCompilerOptions, debugger

'''
setCompilerOptions("noDebug", "noBoundMethods", "noDescriptors", "noGetattrSupport", "noAttributeChecking", "noSourceTracking", "noLineTracking", "noStoreSource")

platform = JS("$pyjs.platform")
sys = None
dynamic = None
Ellipsis = None
JS("""
var $max_float_int = 1;
for (var i = 0; i < 1000; i++) {
    $max_float_int *= 2;
    if ($max_float_int + 1 == $max_float_int) {
        break;
    }
}
$max_int = 0x7fffffff;
$min_int = -0x80000000;
""")

_handle_exception = JS("""function(err) {
    $pyjs.loaded_modules['sys'].save_exception_stack();

    if (!$pyjs.in_try_except) {
        var $pyjs_msg = $pyjs.loaded_modules['sys']._get_traceback(err);
        $pyjs.__active_exception_stack__ = null;
        @{{debugReport}}($pyjs_msg);
    }
    throw err;
};