summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 53ea64c)
raw | patch | inline | side by side (parent: 53ea64c)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Wed, 25 Feb 2004 03:39:53 +0000 (03:39 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Wed, 25 Feb 2004 03:39:53 +0000 (03:39 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2115 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
doc/customizing.txt | patch | blob | history | |
roundup/cgi/client.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index af416111d20d7cf4e8626193b97895661d034453..5c8a5fcbb777d8d03ef0e55e6664d97c608b2d6f 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
- HTMLLinkProperty field() method renders as a field now (thanks darryl)
- all HTML templating methods now automatically check for permissions
(either view or edit as appropriate), greatly simplifying templates
+- cgi Action handlers may now return the actual content to be sent back to
+ the user (rather than using some template)
Fixed:
- mysql documentation fixed to note requirement of 4.0+ and InnoDB
diff --git a/doc/customizing.txt b/doc/customizing.txt
index 5607cdddec29339a9a63f4f32bf5db3a04629299..7205a2fcfd5a275952848d42d87c34743ded61a3 100644 (file)
--- a/doc/customizing.txt
+++ b/doc/customizing.txt
Customising Roundup
===================
-:Version: $Revision: 1.116 $
+:Version: $Revision: 1.117 $
.. This document borrows from the ZopeBook section on ZPT. The original is at:
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
where "myaction" is the name you registered in the previous step.
+Actions may return content to the user
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Actions generally perform some database manipulation and then pass control
+on to the rendering of a template in the current context (see `Determining
+web context`_ for how that works.) Some actions will want to generate the
+actual content returned to the user. Action methods may return their own
+content string to be displayed to the user, overriding the templating step.
+In this situation, we assume that the content is HTML by default. You may
+override the content type indicated to the user by calling ``setHeader``::
+
+ self.client.setHeader('Content-Type', 'text/csv')
+
+This example indicates that the value sent back to the user is actually
+comma-separated value content (eg. something to be loaded into a
+spreadsheet or database).
+
Examples
========
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index 57fdd110c9ca6a4bd0a4bdb93b33257899b2c5f1..5c31b774fe5e2e674cdae96d54a5c3aec85dbd32 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
-# $Id: client.py,v 1.163 2004-02-25 03:24:43 richard Exp $
+# $Id: client.py,v 1.164 2004-02-25 03:39:53 richard Exp $
"""WWW request handler (also used in the stand-alone server).
"""
Note: also cleans One Time Keys, and other "session" based stuff.
"""
sessions = self.db.sessions
- last_clean = sessions.get('last_clean', 'last_use') or 0
+ last_clean = self.db.sessions.get('last_clean', 'last_use') or 0
+ # time to clean?
week = 60*60*24*7
hour = 60*60
now = time.time()
- if now - last_clean > hour:
- # remove aged sessions
- for sessid in sessions.list():
- interval = now - sessions.get(sessid, 'last_use')
- if interval > week:
- sessions.destroy(sessid)
- # remove aged otks
- otks = self.db.otks
- for sessid in otks.list():
- interval = now - otks.get(sessid, '__time')
- if interval > week:
- otks.destroy(sessid)
- sessions.set('last_clean', last_use=time.time())
+ if now - last_clean < hour:
+ return
+
+ self.db.sessions.clean(now)
+ self.db.otks.clean(now)
+ self.db.sessions.set('last_clean', last_use=time.time())
def determine_user(self):
''' Determine who the user is
# get the user from the session
try:
# update the lifetime datestamp
- sessions.set(self.session, last_use=time.time())
+ sessions.updateTimestamp(self.session)
sessions.commit()
user = sessions.get(self.session, 'user')
except KeyError:
self.header()
self.request.wfile.write(content)
+ def setHeader(self, header, value):
+ '''Override a header to be returned to the user's browser.
+ '''
+ self.additional_headers[header] = value
+
def header(self, headers=None, response=None):
'''Put up the appropriate header.
'''