Mercurial > p > roundup > code
changeset 1254:77920c42aeb9
Expose the tracker config as a variable for templating
Homogenise newlines in CGI text submissions [SF#614072]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 09 Oct 2002 01:00:41 +0000 |
| parents | fe67477e678f |
| children | e5af1b963837 |
| files | CHANGES.txt doc/customizing.txt roundup/cgi/client.py roundup/cgi/templating.py |
| diffstat | 4 files changed, 25 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Tue Oct 08 07:28:34 2002 +0000 +++ b/CHANGES.txt Wed Oct 09 01:00:41 2002 +0000 @@ -14,6 +14,8 @@ - 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
--- a/doc/customizing.txt Tue Oct 08 07:28:34 2002 +0000 +++ b/doc/customizing.txt Wed Oct 09 01:00:41 2002 +0000 @@ -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 @@ - *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.
--- a/roundup/cgi/client.py Tue Oct 08 07:28:34 2002 +0000 +++ b/roundup/cgi/client.py Wed Oct 09 01:00:41 2002 +0000 @@ -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 @@ # 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 @@ 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 @@ 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
--- a/roundup/cgi/templating.py Tue Oct 08 07:28:34 2002 +0000 +++ b/roundup/cgi/templating.py Wed Oct 09 01:00:41 2002 +0000 @@ -126,10 +126,10 @@ - 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 @@ 'nothing': None, 'request': request, 'db': HTMLDatabase(client), + 'config': client.instance.config, 'tracker': client.instance, 'utils': TemplatingUtils(client), 'templates': Templates(client.instance.config.TEMPLATES),
