Source

CherryPy / docs / europython2005 / index.html

<!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>