summaryrefslogtreecommitdiff
path: root/docs/europython2005/index.html
blob: 50538b37aa783536485e5abe23ba8758dafd9caf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>CherryPy tutorial</title>
<!-- metadata -->
<meta name="generator" content="S5" />
<meta name="version" content="S5 1.1b5" />
<meta name="presdate" content="20050628" />
<meta name="author" content="Remi Delon" />
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
<!-- style sheet links -->
<link rel="stylesheet" href="s5/theme/slides.css" type="text/css" media="projection" id="slideProj" />
<link rel="stylesheet" href="s5/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
<link rel="stylesheet" href="s5/default/print.css" type="text/css" media="print" id="slidePrint" />
<link rel="stylesheet" href="s5/default/opera.css" type="text/css" media="projection" id="operaFix" />
<!-- S5 JS -->
<script src="s5/default/slides.js" type="text/javascript"></script>
</head>
<body>

<div class="layout">
<div id="controls"><!-- DO NOT EDIT --></div>
<div id="currentSlide"><!-- DO NOT EDIT --></div>
<div id="header"></div>
<div id="footer">
<h1>CherryPy tutorial</h1>
<h2>EuroPython 2005</h2>
</div>
</div>

<div class="presentation">

<div class="slide">
<h1>CherryPy tutorial</h1>
<h3>Remi Delon</h3>
<h4>remi@cherrypy.org</h4>
<h4><a href="http://www.cherrypy.org/" rel="external">http://www.cherrypy.org</a></h4>
<div class="handout"></div>
</div>

<div class="slide">
<h1>Introduction</h1>
<ul>
    <li>Pythonic, object-oriented web development framework</li>
    <li>Runs everywhere python runs</li>
    <li>Requires Python-2.3 or later</li>
    <li>BSD license</li>
    <li>Version 2.1 (used in this tutorial) coming soon</li>
</ul>
</div>

<div class="slide">
<h1>Brief history of CherryPy</h1>
<ul>
    <li>Jun 2002: CherryPy-0.1 released: users wrote .cpy files made of python code + some extensions (ex: CherryClass), then compiled them into one .py file ... bad idea (too unpythonic) ... some interest, but quite limited</li>
    <li>Apr 2004: Last "CP1" release</li>
    <li>Sep 2004: First "CP2" release: pure python code, no more compilation step, templating system separated from the core ... much more interest from the community</li>
    <li>In a few weeks: CherryPy-2.1 release ... another big step forward</li>
</ul>
</div>

<div class="slide">
<h1>Hello, world</h1>
<ul>
    <li>Exposing objects</li>
    <li>Built-in HTTP server</li>
    <li>"development" environment: autoreload, debug information
</ul>
</div>

<div class="slide">
<h1>Hello, you</h1>
<ul>
    <li>Passing parameters to methods</li>
    <li>All parameters (except file uploads) are passed a strings or lists of strings</li>
    <li>GET or POST parameters are passed the same way</li>
</ul>
</div>

<div class="slide">
<h1>Configuring CherryPy</h1>
<ul>
    <li>Through config file</li>
    <li>Programmatically</li>
</ul>
</div>


<div class="slide">
<h1>Url -> object mapping</h1>
<ul>
    <li>Using multiple methods</li>
    <li>Using multiple classes</li>
    <li>Using the "default" method</li>
    <li>Using positional arguments for REST URLs</li>
</ul>
</div>

<div class="slide">
<h1>Using OOP</h1>
<ul>
    <li>Example: using OOP to provide a constant header/footer</li>
</ul>
</div>

<div class="slide">
<h1>Handling file uploads</h1>
<ul>
    <li>File is stored on disk as a temp file</li>
    <li>CherryPy returns a cgi.FieldStorage instance</li>
    <li>Available attributes: file, filename, type, ...</li>
</ul>
</div>

<div class="slide">
<h1>Manipulating cpg.request and cpg.response</h1>
<ul>
    <li>Ex: Reading the Host header from the request</li>
    <li>Ex: Setting the response Content-Type</li>
</ul>
</div>

<div class="slide">
<h1>Using generators</h1>
<ul>
    <li>Returning a generator instead of a string</li>
    <li>Returning a file object</li>
    <li>Set Content-Length manually to stream data to the browser "on-the-fly"</li>
</ul>
</div>

<div class="slide">
<h1>Using filters</h1>
<ul>
    <li>Ex: gzipFilter (uses generators)</li>
    <li>Ex: encodingFilter, decodingFilter</li>
    <li>Ex: staticContentFilter</li>
    <li>Other filters: XML-RPC, Tidy, nsgmls, virtual host, caching, ...</li>
</ul>
</div>

<div class="slide">
<h1>Using sessions</h1>
<ul>
    <li>Sessions are just a regular filter (sessionFilter)</li>
    <li>Provides dictionary-like objects for storing session data</li>
    <li>The default one is cherrypy.sessions.default</li>
</ul>
</div>

<div class="slide">
<h1>Deploying your site for production</h1>
<ul>
    <li>Built-in HTTP server: OK, but no HTTP/1.1 or SSL (yet)</li>
    <li>WSGI interface allows us to use a variety of setups: mod_python, FastCGI, IIS, ...</li>
    <li>Another option: behind Apache with mod_rewrite or mod_proxy (use Apache to serve static data directly)</li>
</ul>
</div>

<div class="slide">
<h1>What's not included in CherryPy</h1>
<ul>
    <li>A form handling module</li>
    <li>A templating system</li>
    <li>An authentication system</li>
    <li>... CherryPy is deliberately staying low-level</li>
    <li>... If you need a higher-level framework, consider Subway or CherryObject (coming soon)</li>
</ul>
</div>

<div class="slide">
<h1>References</h1>
<ul>
    <li>http://www.cherrypy.org</li>
    <li>Documentation: tutorial, FAQ, recipes, ...</li>
    <li>Mailing lists</li>
    <li>IRC channel: #cherrypy on OFTC</li>
</ul>

<div class="slide">
<h1>Near future of CherryPy</h1>
<ul>
    <li>CherryPy-2.1 coming out soon (*lots* of new features)</li>
    <li>CherryPy book (online only for now) coming soon</li>
    <li>Lots of activity at the moment ... More and more contributors</li>
    <li>But we could still use more: feel free to help :-)</li>
</ul>
</div>


<div class="slide">
<h1>Any questions ?</h1>
</div>

</div>

</body>
</html>