From: richard Date: Wed, 9 Oct 2002 01:00:41 +0000 (+0000) Subject: - expose the tracker config as a variable for templating X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5a356a5843f64a28b0f958cb02ee781b9612c31f;p=roundup.git - expose the tracker config as a variable for templating - homogenise newlines in CGI text submissions (sf bug 614072) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1327 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 5d2c2fb..b1e26f9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,8 @@ are given with the most recent entry first. - nicer display of tracker list in roundup-server (sf bug 619769) - fixed some missed renaming instance -> tracker (sf bug 619769) - allow blank passwords again (sf bug 619714) +- expose the tracker config as a variable for templating +- homogenise newlines in CGI text submissions (sf bug 614072) 2002-10-02 0.5.0 diff --git a/doc/customizing.txt b/doc/customizing.txt index fec578b..e77feff 100644 --- a/doc/customizing.txt +++ b/doc/customizing.txt @@ -2,7 +2,7 @@ Customising Roundup =================== -:Version: $Revision: 1.53 $ +:Version: $Revision: 1.54 $ .. This document borrows from the ZopeBook section on ZPT. The original is at: http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx @@ -1032,10 +1032,11 @@ The following variables are available to templates. - *form* The current CGI form information as a mapping of form argument name to value -**tracker** - The current tracker +**config** + This variable holds all the values defined in the tracker config.py file + (eg. TRACKER_NAME, etc.) **db** - The current database, through which db.config may be reached. + The current database, used to access arbitrary database items. **templates** Access to all the tracker templates by name. Used mainly in *use-macro* commands. diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index 635cf72..8ac665d 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.51 2002-10-08 04:11:17 richard Exp $ +# $Id: client.py,v 1.52 2002-10-09 01:00:40 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -1033,7 +1033,8 @@ class Client: # in a nutshell, don't do anything if there's no note or there's no # NOSY if self.form.has_key(':note'): - note = self.form[':note'].value.strip() + # fix the CRLF/CR -> LF stuff + note = fixNewlines(self.form[':note'].value.strip()) if not note: return None, files if not props.has_key('messages'): @@ -1105,6 +1106,15 @@ class Client: link = self.db.classes[link] link.set(nodeid, **{property: nid}) +def fixNewlines(text): + ''' Homogenise line endings. + + Different web clients send different line ending values, but + other systems (eg. email) don't necessarily handle those line + endings. Our solution is to convert all line endings to LF. + ''' + text = text.replace('\r\n', '\n') + return text.replace('\r', '\n') def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): ''' Pull properties for the given class out of the form. @@ -1144,6 +1154,8 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): if isinstance(proptype, hyperdb.String): if not value: continue + # fix the CRLF/CR -> LF stuff + value = fixNewlines(value) elif isinstance(proptype, hyperdb.Password): if not value: # ignore empty password values diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 9f24a19..4c4a13b 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -126,10 +126,10 @@ class RoundupPageTemplate(PageTemplate.PageTemplate): - methods for easy filterspec link generation - *user*, the current user node as an HTMLItem instance - *form*, the current CGI form information as a FieldStorage - *tracker* - The current tracker + *config* + The current tracker config. *db* - The current database, through which db.config may be reached. + The current database, used to access arbitrary database items. ''' def getContext(self, client, classname, request): c = { @@ -137,6 +137,7 @@ class RoundupPageTemplate(PageTemplate.PageTemplate): 'nothing': None, 'request': request, 'db': HTMLDatabase(client), + 'config': client.instance.config, 'tracker': client.instance, 'utils': TemplatingUtils(client), 'templates': Templates(client.instance.config.TEMPLATES),