# HG changeset patch # User Atul Varma # Date 1252647165 25200 # Node ID c2c369402a2e9f75711549875c29d63125db5f18 # Parent 7cbbec55aef6ba5df0f474689768176687c16f22 Added more docs, fixed edge cases. diff -r 7cbbec55aef6 -r c2c369402a2e docs.css --- a/docs.css Thu Sep 10 17:05:05 2009 -0700 +++ b/docs.css Thu Sep 10 22:32:45 2009 -0700 @@ -3,7 +3,7 @@ font-size: 12pt; } -.title { +h1 { font-weight: normal; } diff -r 7cbbec55aef6 -r c2c369402a2e docs.html --- a/docs.html Thu Sep 10 17:05:05 2009 -0700 +++ b/docs.html Thu Sep 10 22:32:45 2009 -0700 @@ -13,6 +13,12 @@

Pydertron is a high-level wrapper for Pydermonkey that provides convenient, secure object wrapping between JS and Python space.

+

Note that Pydertron is just one example of a high-level interface +between Python and JavaScript: it assumes, for instance, that the JS +code it executes isn't trusted, which affects the nature of the +inter-language interaction.

+
+

The Basics

The JsSandbox class encapsulates a JavaScript runtime, context, global object, and a simple SecurableModule implementation that complies with the CommonJS standard. It also provides a high-level bridge between @@ -90,10 +96,42 @@ -1 -

Note that the traceback displayed is actually referring to -JavaScript code: one of Pydertron's helpful conveniences is that -it makes debugging JS code as much like debugging Python code as -possible.

+

Note that the traceback displayed is actually referring to JavaScript +code: one of Pydertron's aims is to make debugging JS code as much +like debugging Python code as possible.

+
+
+

Exceptions

+

Any exceptions raised by wrapped Python functions need to be of type +pydermonkey.error to be propagated into calling JavaScript code; +if they're not, then for security purposes, the entire JavaScript call +stack is unrolled.

+

For example, here's a function that's bound to fail:

+
+
+>>> @jsexposed
+... def fail():
+...   o()
+>>> sandbox.root.fail = fail
+
+
+

Now, even though the following JS code calls the function in a +try-catch block, the JS code doesn't catch anything and its execution +is simply halted:

+
+
+>>> sandbox.run_script("try { fail(); } catch (e) {}",
+...                    stderr=sys.stdout)  #doctest: +ELLIPSIS
+An internal error occurred.
+Traceback (most recent call last):
+...
+NameError: global name 'o' is not defined
+-1
+
+
+

Note that a KeyboardInterrupt triggered while JS is executing will +have similar effect.

+