[seed] [docs] Add context sample code



commit d6cc781232c0d804b831ec1cbe1e9e6163456e5d
Author: Tim Horton <hortont424 gmail com>
Date:   Wed Jul 8 21:58:20 2009 -0400

    [docs] Add context sample code

 doc/reference/tmpl/seed-context.sgml |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/doc/reference/tmpl/seed-context.sgml b/doc/reference/tmpl/seed-context.sgml
index 41ab611..2bf01f4 100644
--- a/doc/reference/tmpl/seed-context.sgml
+++ b/doc/reference/tmpl/seed-context.sgml
@@ -9,8 +9,18 @@ Self-contained JavaScript execution environments
 A #SeedContext provides a complete "universe" for the execution of JavaScript. You can use seed_context_new() to create a sandboxed context that lacks the import system, so it can be used to execute somewhat untrusted JavaScript (as it has no way to access the rest of your system). You can also expose the default set of globals (including "print", "imports", and "Seed") to create more powerful but still self-contained environments within which to execute code.
 </para>
 
-<para>
-The "sandbox" module provides access to this system from the JavaScript side of Seed.
+<example>
+<title>Using a Seed context as a form of sandboxing</title>
+<programlisting>
+...
+ctx = seed_context_create(NULL, NULL);
+script = seed_make_script(ctx, "print(imports)", NULL, 0);
+// nothing is printed, because imports is undefined, because we're in a sandbox
+...
+</programlisting>
+</example>
+
+<para>The "sandbox" module provides access to this system from the JavaScript side of Seed.
 </para>
 
 <!-- ##### SECTION See_Also ##### -->



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]