Skip to content

Commit f6d6aad

Browse files
author
Philip Guo
committed
some documentation updates
1 parent b2c0c80 commit f6d6aad

4 files changed

Lines changed: 67 additions & 49 deletions

File tree

README

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,62 @@ Using this application, teachers and students can write small Python
2727
code snippets together and see what happens to the data structures when
2828
the code gets executed.
2929

30-
---
31-
3230
Try it out live at: http://people.csail.mit.edu/pgbovine/python/
3331

34-
---
32+
======
33+
System architecture overview:
34+
35+
The Online Python Tutor is implemented as a web application, with a
36+
JavaScript front-end making AJAX calls to a pure-Python back-end.
37+
38+
The back-end has been tested on an Apache server running Python 2.5
39+
through CGI. Note that it will probably fail in subtle ways on other
40+
Python 2.X (and will DEFINITELY fail on Python 3.X). Peter Wentworth
41+
has create a port to Python 3.X, and hopefully we can soon integrate his
42+
code into my repository.
43+
44+
45+
The front-end is HTML/javascript (using the jQuery library). It's
46+
responsible for the input text box, submitting the Python code (as
47+
plaintext) to the back-end, receiving an execution trace from the
48+
back-end, and then rendering that trace as data structure
49+
visualizations. The front-end code is publicly available in these 5
50+
files in the current directory:
51+
52+
index.html
53+
edu-python.js
54+
edu-python.css
55+
jquery-1.3.2.min.js
56+
jquery.textarea.js
57+
58+
59+
The back-end is a server-side app that takes Python script source code
60+
as input, executes the entire script (up to 100 executed lines, to
61+
prevent infinite loops), and collects a full trace of all variable
62+
values (i.e., data structures) after each line is executed. It then
63+
sends that complete trace to the front-end in an encoded JSON format.
64+
The front-end then parses that trace, which is how it's able to
65+
single-step forwards AND backwards through execution.
66+
67+
The back-end files reside in the cgi-bin/ sub-directory in this
68+
repository:
69+
70+
cgi-bin/web_exec.py - the CGI entrance point to the back-end
71+
cgi-bin/pg_logger.py - the 'meat' of the back-end
72+
cgi-bin/pg_encoder.py - encodes Python data into JSON
73+
cgi-bin/demjson.py - 3rd-party JSON module, since Python 2.5
74+
- doesn't have the built-in 'import json'
75+
cgi-bin/create_db.py - for optional sqlite query logging
76+
cgi-bin/db_common.py - for optional sqlite query logging
77+
cgi-bin/.htaccess - for Apache CGI execute permissions
78+
cgi-bin/run_tests.py - simple regression tests
79+
80+
81+
Due to the AJAX same-origin policy, the front-end and back-end must be
82+
deployed on the same server (unless you do some fancy proxy magic).
83+
84+
85+
======
3586
Original vision (from January 2010):
3687

3788
I want to create a web-based interactive learning platform for students
@@ -64,43 +115,3 @@ The PDB debugger (Lib/pdb.py) is written in pure Python:
64115
- the bdb debugger framework is the C module that pdb calls
65116
http://docs.python.org/library/bdb.html
66117

67-
---
68-
69-
Informal system architecture overview --- sent in an email on 2010-09-05
70-
71-
'''
72-
i'll give you a bit of background on the architecture of the system:
73-
74-
1.) The front-end is HTML/javascript (using the jQuery library) ... it's
75-
responsible for the input text box, submitting the Python code (as
76-
plaintext) to the backend, receiving an execution trace from the
77-
backend, and then rendering that trace as data structure visualizations.
78-
all the front-end code is already publicly available in these 5 files:
79-
80-
http://people.csail.mit.edu/pgbovine/python/index.html
81-
http://people.csail.mit.edu/pgbovine/python/jquery-1.3.2.min.js
82-
http://people.csail.mit.edu/pgbovine/python/jquery.textarea.js
83-
http://people.csail.mit.edu/pgbovine/python/edu-python.js
84-
http://people.csail.mit.edu/pgbovine/python/edu-python.css
85-
86-
87-
2.) The back-end is a server-side app that takes Python script source
88-
code as input, executes the entire script (up to 100 executed lines, to
89-
prevent infinite loops), and collects a full trace of all variable
90-
values after each line is executed. It then sends that trace to the
91-
front-end in an encoded JSON format. The front-end then parses that
92-
trace, which is how it's able to single-step forwards AND backwards
93-
through execution.
94-
95-
The back-end currently runs on my server, and I think the most
96-
convenient thing to do right now is to simply invoke it as a web
97-
service. This is the URL:
98-
99-
http://people.csail.mit.edu/pgbovine/python/cgi-bin/web_exec.py
100-
101-
and it expects only ONE following parameter to be passed in via POST.
102-
that parameter is called 'user_script', and it's a string that contains
103-
the text of the script to be executed. so the interface is pretty
104-
simple ;)
105-
'''
106-

cgi-bin/pg_logger.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
# This is the meat of the Online Python Tutor backend. It implements a
18+
19+
# This is the meat of the Online Python Tutor back-end. It implements a
1920
# full logger for Python program execution (based on pdb, the standard
20-
# Python debugger via the bdb module).
21+
# Python debugger imported via the bdb module), printing out the values
22+
# of all in-scope data structures after each executed instruction.
2123

2224
# Note that I've only tested this logger on Python 2.5, so it will
23-
# probably fail in subtle way on other Python 2.X (and will DEFINITELY
25+
# probably fail in subtle ways on other Python 2.X (and will DEFINITELY
2426
# fail on Python 3.X).
2527

2628

cgi-bin/web_exec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919

2020

21-
# Executes the Online Python Tutor backend as a CGI script, which
21+
# Executes the Online Python Tutor back-end as a CGI script, which
2222
# accepts one POST parameter, 'user_script', containing the string
2323
# contents of the Python script that the user wants to execute.
2424
#
2525
# Returns a complete JSON execution trace to the front-end.
2626
#
27-
# This version works using Python 2.5 on the MIT CSAIL servers.
28-
# (note that Python 2.4 doesn't seem to work on CSAIL, but Python 2.5 does)
27+
# This version uses Python 2.5 on the MIT CSAIL servers.
28+
# (note that Python 2.4 doesn't work on CSAIL, but Python 2.5 does)
2929
#
3030
# If you want to run this script, then you'll need to change the
3131
# shebang line at the top of this file to point to your system's Python.

edu-python.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
2020
*/
2121

22+
// The Online Python Tutor front-end, which calls the cgi-bin/web_exec.py
23+
// back-end with a string representing the user's script POST['user_script']
24+
// and receives a complete execution trace, which it parses and displays to HTML.
25+
26+
2227
var localTesting = false; // if this is true, mock-data.js had also better be included
2328

2429

0 commit comments

Comments
 (0)