Use new PTL syntax. (quixote/demo/session.ptl)
Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Tue, 26 Nov 2002 18:54:14 -0500
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /home/cvs/quixote/demo
In directory hewson:/tmp/cvs-serv7922
Modified Files:
session.ptl
Log Message:
Use new PTL syntax.
Index: session.ptl
===================================================================
RCS file: /home/cvs/quixote/demo/session.ptl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- session.ptl 20 Nov 2002 19:43:22 -0000 1.3
+++ session.ptl 26 Nov 2002 23:54:12 -0000 1.4
@@ -7,14 +7,13 @@
from quixote import get_session_manager
from quixote.errors import AccessError, QueryError
-from quixote.html import html_quote
_q_exports = ['login', 'logout']
# Typical stuff for any Quixote app.
-template page_header (title):
+def page_header [html] (title):
'''\
<html>
<head><title>%s</title></head>
@@ -22,7 +21,7 @@
<h1>%s</h1>
''' % (title, title)
-template page_footer ():
+def page_footer [html] ():
'''\
</body>
</html>
@@ -32,7 +31,7 @@
# We include the login form on two separate pages, so it's been factored
# out to a separate template.
-template login_form ():
+def login_form [html] ():
'''
<form method="POST" action="login">
<input name="name" width=30>
@@ -41,7 +40,7 @@
'''
-template _q_index (request):
+def _q_index [html] (request):
page_header("Quixote Session Management Demo")
session = request.session
@@ -61,8 +60,7 @@
'''
login_form()
else:
- ('<p>Hello, %s. Good to see you again.</p>\n'
- % html_quote(session.user))
+ '<p>Hello, %s. Good to see you again.</p>\n' % session.user
'''
You can now:
@@ -79,7 +77,7 @@
"""\
<p>Your session is <code>%s</code><br>
You have made %d request(s) (including this one) in this session.</p>
-""" % (html_quote(repr(session)), session.num_requests)
+""" % (repr(session), session.num_requests)
# The session manager is the collection of all sessions managed by
# the current publisher, ie. in this process. Poking around in the
@@ -92,12 +90,12 @@
It has %d session(s) in it right now:</p>
<table border=1>
<tr><th>session id</th><th>user</th><th>num requests</th></tr>
-''' % (html_quote(repr(mgr)), len(session_ids))
+''' % (repr(mgr), len(session_ids))
for sess_id in session_ids:
sess = mgr[sess_id]
(' <tr><td>%s</td><td>%s</td><td>%d</td>\n'
% (sess.id,
- sess.user and html_quote(sess.user) or "<i>none</i>",
+ sess.user and sess.user or "<i>none</i>",
sess.num_requests))
'<table>\n'
@@ -110,7 +108,7 @@
# Quixote (just as it's a fairly common idiom with CGI scripts -- it's
# just cleaner with Quixote).
-template login (request):
+def login [html] (request):
page_header("Quixote Session Demo: Login")
session = request.session
@@ -122,7 +120,7 @@
session.user = user
- '<p>Welcome, %s! Thank you for logging in.</p>\n' % html_quote(user)
+ '<p>Welcome, %s! Thank you for logging in.</p>\n' % user
'<a href="./">back to start</a>\n'
# No form data to process, so generate the login form instead. When
@@ -140,7 +138,7 @@
# cookie. The only code necessary is the call to
# SessionManager.expire_session() -- the rest is just user interface.
-template logout (request):
+def logout [html] (request):
page_header("Quixote Session Demo: Logout")
session = request.session
if session.user: