~ubuntu-branches/ubuntu/gutsy/libapache2-mod-python/gutsy

« back to all changes in this revision

Viewing changes to doc-html/pyapi-sess-example.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-07-07 13:18:35 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060707131835-zfp1vupanjj2e77y
Tags: 3.2.8-1ubuntu1
* Merge to Debian unstable.
* Remaining Ubuntu change: debian/{control,rules}: Drop python 2.3 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
2
<html>
 
3
<head>
 
4
<link rel="STYLESHEET" href="modpython.css" type='text/css'>
 
5
<link rel="first" href="modpython.html" title='Mod_python Manual'>
 
6
<link rel='contents' href='contents.html' title="Contents">
 
7
<link rel='index' href='genindex.html' title='Index'>
 
8
<link rel='last' href='about.html' title='About this document...'>
 
9
<link rel='help' href='about.html' title='About this document...'>
 
10
<LINK REL="prev" href="pyapi-sess-classes.html">
 
11
<LINK REL="parent" href="pyapi-sess.html">
 
12
<LINK REL="next" href="pyapi-psp.html">
 
13
<meta name='aesop' content='information'>
 
14
<META NAME="description" CONTENT="Examples">
 
15
<META NAME="keywords" CONTENT="modpython">
 
16
<META NAME="resource-type" CONTENT="document">
 
17
<META NAME="distribution" CONTENT="global">
 
18
<title>4.8.2 Examples</title>
 
19
</head>
 
20
<body>
 
21
<DIV CLASS="navigation">
 
22
<table align="center" width="100%" cellpadding="0" cellspacing="2">
 
23
<tr>
 
24
<td><a rel="prev" title="4.8.1 Classes" 
 
25
  href="pyapi-sess-classes.html"><img src='previous.gif'
 
26
  border='0' height='32'  alt='Previous Page' width='32'></A></td>
 
27
<td><a rel="parent" title="4.8 Session - Session" 
 
28
  href="pyapi-sess.html"><img src='up.gif'
 
29
  border='0' height='32'  alt='Up One Level' width='32'></A></td>
 
30
<td><a rel="next" title="4.9 psp - Python" 
 
31
  href="pyapi-psp.html"><img src='next.gif'
 
32
  border='0' height='32'  alt='Next Page' width='32'></A></td>
 
33
<td align="center" width="100%">Mod_python Manual</td>
 
34
<td><a rel="contents" title="Table of Contents" 
 
35
  href="contents.html"><img src='contents.gif'
 
36
  border='0' height='32'  alt='Contents' width='32'></A></td>
 
37
<td><img src='blank.gif'
 
38
  border='0' height='32'  alt='' width='32'></td>
 
39
<td><a rel="index" title="Index" 
 
40
  href="genindex.html"><img src='index.gif'
 
41
  border='0' height='32'  alt='Index' width='32'></A></td>
 
42
</tr></table>
 
43
<b class="navlabel">Previous:</b>
 
44
<a class="sectref" rel="prev" href="pyapi-sess-classes.html">4.8.1 Classes</A>
 
45
<b class="navlabel">Up:</b>
 
46
<a class="sectref" rel="parent" href="pyapi-sess.html">4.8 Session - Session</A>
 
47
<b class="navlabel">Next:</b>
 
48
<a class="sectref" rel="next" href="pyapi-psp.html">4.9 psp - Python</A>
 
49
<br><hr>
 
50
</DIV>
 
51
<!--End of Navigation Panel-->
 
52
 
 
53
<H2><A NAME="SECTION006820000000000000000">&nbsp;</A>
 
54
<BR>
 
55
4.8.2 Examples
 
56
</H2>
 
57
The following example demonstrates a simple hit counter.
 
58
 
 
59
<P>
 
60
<div class="verbatim"><pre>
 
61
from mod_python import Session
 
62
 
 
63
def handler(req):
 
64
    session = Session.Session(req)
 
65
 
 
66
    try:
 
67
        session['hits'] += 1
 
68
    except:
 
69
        session['hits'] = 1
 
70
 
 
71
    session.save()
 
72
 
 
73
    req.content_type = 'text/plain'
 
74
    req.write('Hits: %d\n' % session['hits'])
 
75
    return apache.OK
 
76
</pre></div>
 
77
 
 
78
<P>
 
79
 
 
80
<DIV CLASS="navigation">
 
81
<p><hr>
 
82
<table align="center" width="100%" cellpadding="0" cellspacing="2">
 
83
<tr>
 
84
<td><a rel="prev" title="4.8.1 Classes" 
 
85
  rel="prev" title="4.8.1 Classes" 
 
86
  href="pyapi-sess-classes.html"><img src='previous.gif'
 
87
  border='0' height='32'  alt='Previous Page' width='32'></A></td>
 
88
<td><a rel="parent" title="4.8 Session - Session" 
 
89
  rel="parent" title="4.8 Session - Session" 
 
90
  href="pyapi-sess.html"><img src='up.gif'
 
91
  border='0' height='32'  alt='Up One Level' width='32'></A></td>
 
92
<td><a rel="next" title="4.9 psp - Python" 
 
93
  rel="next" title="4.9 psp - Python" 
 
94
  href="pyapi-psp.html"><img src='next.gif'
 
95
  border='0' height='32'  alt='Next Page' width='32'></A></td>
 
96
<td align="center" width="100%">Mod_python Manual</td>
 
97
<td><a rel="contents" title="Table of Contents" 
 
98
  rel="contents" title="Table of Contents" 
 
99
  href="contents.html"><img src='contents.gif'
 
100
  border='0' height='32'  alt='Contents' width='32'></A></td>
 
101
<td><img src='blank.gif'
 
102
  border='0' height='32'  alt='' width='32'></td>
 
103
<td><a rel="index" title="Index" 
 
104
  rel="index" title="Index" 
 
105
  href="genindex.html"><img src='index.gif'
 
106
  border='0' height='32'  alt='Index' width='32'></A></td>
 
107
</tr></table>
 
108
<b class="navlabel">Previous:</b>
 
109
<a class="sectref" rel="prev" href="pyapi-sess-classes.html">4.8.1 Classes</A>
 
110
<b class="navlabel">Up:</b>
 
111
<a class="sectref" rel="parent" href="pyapi-sess.html">4.8 Session - Session</A>
 
112
<b class="navlabel">Next:</b>
 
113
<a class="sectref" rel="next" href="pyapi-psp.html">4.9 psp - Python</A>
 
114
<hr>
 
115
<span class="release-info">Release 3.2.8, documentation updated on February 19, 2006.</span>
 
116
</DIV>
 
117
<!--End of Navigation Panel-->
 
118
 
 
119
</BODY>
 
120
</HTML>