Skip to content

Commit ced2274

Browse files
author
Richard Jones
committed
Various bug fixes.
- fix handling of invalid date input [SF#1102165] - retain Boolean selections in edit error handling [SF#1101492] - fix bug in date editing in Metakit - fixed up date spec usage string - note python 2.3 requirement in announcement and installation docs
1 parent f1235ee commit ced2274

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Fixed:
1717
1119475)
1818
- better edit conflict handling (sf bug 1118790)
1919
- consistent text searching behaviour (AND everywhere) (sf bug 1101036)
20+
- fix handling of invalid date input (sf bug 1102165)
21+
- retain Boolean selections in edit error handling (sf bug 1101492)
2022

2123

2224
2005-01-13 0.8.0b2
@@ -88,6 +90,7 @@ Fixed:
8890
- quote full-text search text in URL generation
8991
- fixed problem migrating mysql databases
9092
- fix search_checkboxes macro (sf patch 1113828)
93+
- fix bug in date editing in Metakit
9194

9295

9396
2005-01-06 0.7.11

doc/announcement.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ First up, big thanks go to alexander smishlajev who has done some really
44
good work getting the i18n and new configuration components of this release
55
going.
66

7+
Please note that Roundup now requires python 2.3 or later.
8+
79
Version 0.8 introduces far too many features to list here so I've put
810
together a What's New page:
911

1012
http://roundup.sourceforge.net/doc-0.8/whatsnew-0.8.html
1113

12-
This is a bugfix release, fixing:
14+
0.8b3 is a bugfix release, fixing:
1315

1416

1517
If you're upgrading from an older version of Roundup you *must* follow
1618
the "Software Upgrade" guidelines given in the maintenance documentation.
1719

18-
Roundup requires python 2.1.3 or later for correct operation.
20+
Roundup requires python 2.3 or later for correct operation.
1921

2022
To give Roundup a try, just download (see below), unpack and run::
2123

roundup/backends/back_metakit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.90 2005-02-13 22:37:00 richard Exp $
1+
# $Id: back_metakit.py,v 1.91 2005-02-14 00:06:55 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -771,7 +771,10 @@ def set_inner(self, nodeid, **propvalues):
771771
setattr(row, key, 0)
772772
else:
773773
setattr(row, key, int(calendar.timegm(value.get_tuple())))
774-
changes[key] = str(oldvalue)
774+
if oldvalue is None:
775+
changes[key] = oldvalue
776+
else:
777+
changes[key] = str(oldvalue)
775778
propvalues[key] = str(value)
776779

777780
elif isinstance(prop, hyperdb.Interval):

roundup/cgi/templating.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,11 @@ def history(self, direction='descending', dre=re.compile('^\d+$')):
935935
current[k] = old
936936

937937
elif isinstance(prop, hyperdb.Date) and args[k]:
938-
d = date.Date(args[k],
939-
translator=self._client).local(timezone)
938+
if args[k] is None:
939+
d = ''
940+
else:
941+
d = date.Date(args[k],
942+
translator=self._client).local(timezone)
940943
cell.append('%s: %s'%(self._(k), str(d)))
941944
if current.has_key(k):
942945
cell[-1] += ' -> %s' % current[k]
@@ -1331,8 +1334,13 @@ def field(self):
13311334
if not self.is_edit_ok():
13321335
return self.plain()
13331336

1334-
checked = self._value and "checked" or ""
1335-
if self._value:
1337+
value = self._value
1338+
if isinstance(value, str) or isinstance(value, unicode):
1339+
value = value.strip().lower() in ('checked', 'yes', 'true',
1340+
'on', '1')
1341+
1342+
checked = value and "checked" or ""
1343+
if value:
13361344
s = self.input(type="radio", name=self._formname, value="yes",
13371345
checked="checked")
13381346
s += 'Yes'
@@ -1354,7 +1362,8 @@ def __init__(self, client, classname, nodeid, prop, name, value,
13541362
anonymous=0, offset=None):
13551363
HTMLProperty.__init__(self, client, classname, nodeid, prop, name,
13561364
value, anonymous=anonymous)
1357-
if self._value:
1365+
if self._value and not (isinstance(self._value, str) or
1366+
isinstance(self._value, unicode)):
13581367
self._value.setTranslator(self._client.translator)
13591368
self._offset = offset
13601369

@@ -1410,7 +1419,9 @@ def field(self, size=30, default=None, format=_marker):
14101419
else:
14111420
return self.pretty(format)
14121421

1413-
if self._value is None:
1422+
value = self._value
1423+
1424+
if value is None:
14141425
if default is None:
14151426
raw_value = None
14161427
else:
@@ -1424,12 +1435,16 @@ def field(self, size=30, default=None, format=_marker):
14241435
raise ValueError, _('default value for '
14251436
'DateHTMLProperty must be either DateHTMLProperty '
14261437
'or string date representation.')
1438+
elif isinstance(value, str) or isinstance(value, unicode):
1439+
# most likely erroneous input to be passed back to user
1440+
value = cgi.escape(str(value), 1)
1441+
return self.input(name=self._formname, value=value, size=size)
14271442
else:
1428-
raw_value = self._value
1443+
raw_value = value
14291444

14301445
if raw_value is None:
14311446
value = ''
1432-
elif type(raw_value) is type(''):
1447+
elif isinstance(raw_value, str) or isinstance(raw_value, unicode):
14331448
if format is self._marker:
14341449
value = raw_value
14351450
else:
@@ -1632,8 +1647,8 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16321647
options = linkcl.filter(None, conditions, sort_on, (None, None))
16331648

16341649
# make sure we list the current value if it's retired
1635-
if self._value and self._value not in options:
1636-
options.insert(0, self._value)
1650+
if value and value not in options:
1651+
options.insert(0, value)
16371652

16381653
for optionid in options:
16391654
# get the option value, and if it's None use an empty string
@@ -1647,6 +1662,8 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16471662
# figure the label
16481663
if showid:
16491664
lab = '%s%s: %s'%(self._prop.classname, optionid, option)
1665+
elif not option:
1666+
lab = '%s%s'%(self._prop.classname, optionid)
16501667
else:
16511668
lab = option
16521669

roundup/date.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: date.py,v 1.78 2005-01-03 03:05:31 richard Exp $
18+
# $Id: date.py,v 1.79 2005-02-14 00:06:54 richard Exp $
1919

2020
"""Date, time and time interval handling.
2121
"""
@@ -152,7 +152,6 @@ def __init__(self, spec='.', offset=0, add_granularity=0, translator=i18n):
152152
except:
153153
raise ValueError, 'Unknown spec %r'%spec
154154

155-
usagespec='[yyyy]-[mm]-[dd].[H]H:MM[:SS.SSS][offset]'
156155
def set(self, spec, offset=0, date_re=re.compile(r'''
157156
((?P<y>\d\d\d\d)([/-](?P<m>\d\d?)([/-](?P<d>\d\d?))?)? # yyyy[-mm[-dd]]
158157
|(?P<a>\d\d?)[/-](?P<b>\d\d?))? # or mm-dd
@@ -177,7 +176,9 @@ def set(self, spec, offset=0, date_re=re.compile(r'''
177176
# not serialised data, try usual format
178177
m = date_re.match(spec)
179178
if m is None:
180-
raise ValueError, self._('Not a date spec: %s') % self.usagespec
179+
raise ValueError, self._('Not a date spec: '
180+
'"yyyy-mm-dd", "mm-dd", "HH:MM", "HH:MM:SS" or '
181+
'"yyyy-mm-dd.HH:MM:SS.SSS"')
181182

182183
info = m.groupdict()
183184

@@ -228,8 +229,9 @@ def set(self, spec, offset=0, date_re=re.compile(r'''
228229
try:
229230
self.applyInterval(Interval(info['o'], allowdate=0))
230231
except ValueError:
231-
raise ValueError, self._('%r not a date spec (%s)')%(spec,
232-
self.usagespec)
232+
raise ValueError, self._('%r not a date / time spec '
233+
'"yyyy-mm-dd", "mm-dd", "HH:MM", "HH:MM:SS" or '
234+
'"yyyy-mm-dd.HH:MM:SS.SSS"')%(spec,)
233235

234236
def addInterval(self, interval):
235237
''' Add the interval to this date, returning the date tuple

0 commit comments

Comments
 (0)