You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a0e3522
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: v3/docs/developer-overview.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ I'm assuming that you're competent in Python, JavaScript, command-line-fu, and G
12
12
and [command-line BS](http://www.pgbovine.net/command-line-bullshittery.htm).
13
13
14
14
This guide isn't meant to be comprehensive; rather, it's a starting point for learning about the code
15
-
and development workflow. You will undoubtedly still be confused about details after reading it, so
15
+
and development workflow. You may still be confused about details after reading it, so
16
16
feel free to email philip@pgbovine.net if you have questions.
17
17
18
18
@@ -32,22 +32,20 @@ And then run:
32
32
Use `python3` if you want to test the Python 3 backend. Note that when you run with bottle, you will **always trigger the backend for the version of Python used to invoke it**, so the Python 2/3 language toggle selector on the frontend is meaningless. You will also not be able to test other language backends locally.
33
33
34
34
35
-
If all goes well, when you visit this URL, you should see the Python Tutor visualizer:
35
+
If all goes well, when you visit this URL, you should see the Python Tutor visualizer:http://localhost:8003/visualize.html
36
36
37
-
http://localhost:8003/visualize.html
38
-
39
-
Note that you can run bottle with both Python 2 and 3.
37
+
And the live programming mode is here: http://localhost:8003/live.html
40
38
41
39
However, **only** run this app locally for testing, not in production, since all security checks are disabled.
42
40
43
41
44
42
## Overall system architecture
45
43
46
44
OPT consists of a pure-Python backend and an HTML/CSS/JavaScript frontend.
47
-
Here is a typical user interaction sequence:
45
+
Here is a typical user interaction sequence for Python (this will differ for other languages):
48
46
49
47
1. The user visits [visualize.html](http://pythontutor.com/visualize.html) and types in Python code in the web-based text editor.
50
-
2. The user hits the "Visualize execution" button.
48
+
2. The user hits the "Visualize Execution" button.
51
49
3. The OPT frontend sends the user's Python code as a string to the backend by making an Ajax GET request.
52
50
4. The backend executes the Python code under the supervision of the Python [bdb](http://docs.python.org/library/bdb.html) debugger, produces an execution trace, and sends that trace back to the frontend in JSON format.
53
51
5. The frontend switches to a visualization display, parses the execution trace, and renders the appropriate stack frames, heap objects, and pointers.
@@ -60,6 +58,7 @@ The frontend consists of:
60
58
visualize.html
61
59
css/opt-frontend.css
62
60
js/opt-frontend.js
61
+
js/opt-frontend-common.js
63
62
css/pytutor.css
64
63
js/pytutor.js
65
64
<a bunch of auxiliary css and js files such as libraries>
@@ -79,19 +78,19 @@ to embed on the same webpage without them interfering with one another.
79
78
`opt-frontend.[js|css]` contain code that is specific to the `visualize.html` page and doesn't make sense for, say,
80
79
embedding OPT visualizations into other webpages.
81
80
82
-
The backend consists of:
81
+
The Python backend consists of:
83
82
```
84
83
pg_logger.py - the main entry point to the OPT backend
85
84
pg_encoder.py - encodes the trace format into JSON to send to frontend
86
85
generate_json_trace.py - script to test the backend independent of the frontend
87
-
app.yaml, pythontutor.py - files for deploying on Google App Engine
86
+
app.yaml, pythontutor.py - files for deploying on Google App Engine (obsolete)
88
87
web_exec.py - example CGI script for deploying backend on CGI-enabled webservers
89
88
```
90
89
91
-
The backend works with both Python 2 and 3. (Other language backends are located in [v4-cokapi/](https://github.com/pgbovine/OnlinePythonTutor/tree/master/v4-cokapi), not in v3/)
90
+
This backend works with both Python 2 and 3. (Other language backends are located in [v4-cokapi/](https://github.com/pgbovine/OnlinePythonTutor/tree/master/v4-cokapi), not in v3/)
92
91
93
92
94
-
## Hacking the backend
93
+
## Hacking the Python backend
95
94
96
95
To modify the Python backend, you will mainly need to understand `pg_logger.py` and `pg_encoder.py`.
97
96
@@ -115,7 +114,7 @@ This data is exactly what the backend sends to the frontend.
115
114
But for testing purposes, I've made the trace more human-readable.)
116
115
117
116
Second, when you're "print debugging" in the backend, you can't simply print to stdout, since `pg_logger.py`
118
-
*redirects* stdout to a buffer. Instead, you need to write all of your print statements as:
117
+
*redirects* stdout to a buffer. Instead, you need to write all of your print statements (in Python 2) as:
0 commit comments