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 committed Feb 1, 2017
1 parent 1bbddec commit 57b997b
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
Original file line number Diff line number Diff line change
@@ -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 57b997b

Please sign in to comment.