Skip to content

Commit

Permalink
begin documenting usage and and upgarde of dependencies, also comment…
Browse files Browse the repository at this point in the history
…ing source code in compile
  • Loading branch information
loechel authored and Michael Howitz committed Feb 3, 2017
1 parent f8c6f2c commit 6f1b522
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Empty file.
59 changes: 59 additions & 0 deletions docs/usage/index.rst
@@ -0,0 +1,59 @@
Usage of RestrictedPython
=========================

Basics
------

RestrictedPython do have tree major scopes:

* compile_restricted methods

* compile_restricted
* compile_restricted_exec
* compile_restricted_eval
* compile_restricted_single
* compile_restricted_function

* restricted builtins

* safe_builtins
* limited_builtins
* utility_builtins

* Helper Moduls

* PrintCollector

heading
-------

The general workflow to execute Python code that is loaded within a Python program is:

.. code:: Python
source_code = """
def do_something():
pass
"""
byte_code = compile(source_code, filename='<inline code>', mode='exec')
exec(byte_code)
do_something()
With RestrictedPython that workflow should be as straight forward as possible:

.. code:: Python
from RestrictedPython import compile_restricted as compile
source_code = """
def do_something():
pass
"""
byte_code = compile(source_code, filename='<inline code>', mode='exec')
exec(byte_code)
do_something()
With that simple addition ``from RestrictedPython import compile_restricted as compile`` it uses a predefined policy that checks and modify the source code and checks against restricted subset of the Python language.
Execution of the compiled source code is still against the full avaliable set of library modules and methods.

0 comments on commit 6f1b522

Please sign in to comment.