Skip to content

Commit 5be72ff

Browse files
author
Richard Jones
committed
Expose the tracker config as a variable for templating
Homogenise newlines in CGI text submissions [SF#614072]
1 parent 7a0d96b commit 5be72ff

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ are given with the most recent entry first.
1414
- nicer display of tracker list in roundup-server (sf bug 619769)
1515
- fixed some missed renaming instance -> tracker (sf bug 619769)
1616
- allow blank passwords again (sf bug 619714)
17+
- expose the tracker config as a variable for templating
18+
- homogenise newlines in CGI text submissions (sf bug 614072)
1719

1820

1921
2002-10-02 0.5.0

doc/customizing.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.53 $
5+
:Version: $Revision: 1.54 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1032,10 +1032,11 @@ The following variables are available to templates.
10321032
- *form*
10331033
The current CGI form information as a mapping of form argument
10341034
name to value
1035-
**tracker**
1036-
The current tracker
1035+
**config**
1036+
This variable holds all the values defined in the tracker config.py file
1037+
(eg. TRACKER_NAME, etc.)
10371038
**db**
1038-
The current database, through which db.config may be reached.
1039+
The current database, used to access arbitrary database items.
10391040
**templates**
10401041
Access to all the tracker templates by name. Used mainly in *use-macro*
10411042
commands.

roundup/cgi/client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.51 2002-10-08 04:11:17 richard Exp $
1+
# $Id: client.py,v 1.52 2002-10-09 01:00:40 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -1033,7 +1033,8 @@ def _handle_message(self):
10331033
# in a nutshell, don't do anything if there's no note or there's no
10341034
# NOSY
10351035
if self.form.has_key(':note'):
1036-
note = self.form[':note'].value.strip()
1036+
# fix the CRLF/CR -> LF stuff
1037+
note = fixNewlines(self.form[':note'].value.strip())
10371038
if not note:
10381039
return None, files
10391040
if not props.has_key('messages'):
@@ -1105,6 +1106,15 @@ def _post_editnode(self, nid):
11051106
link = self.db.classes[link]
11061107
link.set(nodeid, **{property: nid})
11071108

1109+
def fixNewlines(text):
1110+
''' Homogenise line endings.
1111+
1112+
Different web clients send different line ending values, but
1113+
other systems (eg. email) don't necessarily handle those line
1114+
endings. Our solution is to convert all line endings to LF.
1115+
'''
1116+
text = text.replace('\r\n', '\n')
1117+
return text.replace('\r', '\n')
11081118

11091119
def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
11101120
''' 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+$')):
11441154
if isinstance(proptype, hyperdb.String):
11451155
if not value:
11461156
continue
1157+
# fix the CRLF/CR -> LF stuff
1158+
value = fixNewlines(value)
11471159
elif isinstance(proptype, hyperdb.Password):
11481160
if not value:
11491161
# ignore empty password values

roundup/cgi/templating.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,18 @@ class RoundupPageTemplate(PageTemplate.PageTemplate):
126126
- methods for easy filterspec link generation
127127
- *user*, the current user node as an HTMLItem instance
128128
- *form*, the current CGI form information as a FieldStorage
129-
*tracker*
130-
The current tracker
129+
*config*
130+
The current tracker config.
131131
*db*
132-
The current database, through which db.config may be reached.
132+
The current database, used to access arbitrary database items.
133133
'''
134134
def getContext(self, client, classname, request):
135135
c = {
136136
'options': {},
137137
'nothing': None,
138138
'request': request,
139139
'db': HTMLDatabase(client),
140+
'config': client.instance.config,
140141
'tracker': client.instance,
141142
'utils': TemplatingUtils(client),
142143
'templates': Templates(client.instance.config.TEMPLATES),

0 commit comments

Comments
 (0)