Merge lp:~vorlon/summit/strptime-usage into lp:summit

Proposed by Steve Langasek on 2014-04-12
Status: Needs review
Proposed branch: lp:~vorlon/summit/strptime-usage
Merge into: lp:summit
Diff against target: 33 lines (+8/-3)
2 files modified
summit/common/widgets.py (+6/-1)
summit/version.py (+2/-2)
To merge this branch: bzr merge lp:~vorlon/summit/strptime-usage
Reviewer Review Type Date Requested Status
Michael Hall (community) 2014-04-12 Needs Information on 2014-04-15
Review via email: mp+215540@code.launchpad.net

Description of the change

It's quite possible that I've done something wrong, but from what I can see the decompress() function fails consistently when trying to parse an existing datetime setting from the database because it will never be in HH:MM AM/PM form, but always HH:MM:SS. So this change is needed to make the form submission work for me.

To post a comment you must log in.
lp:~vorlon/summit/strptime-usage updated on 2014-04-12
223. By Steve Langasek on 2014-04-12

Apparently we can get this code path called with two different time formats; dunno why, but this addresses the problem at least for now

224. By Steve Langasek on 2014-04-12

Make the custom DateTime widget nullable, like the upstream one is

José Antonio Rey (jose) wrote :

Steve,

I think you wanted to push this against lp:summit/production instead of lp:summit?

Chris Johnston (cjohnston) wrote :

Why would we want to push code straight to production?
On Apr 12, 2014 6:30 PM, "José Antonio Rey" <email address hidden> wrote:

> Steve,
>
> I think you wanted to push this against lp:summit/production instead of
> lp:summit?
> --
> https://code.launchpad.net/~vorlon/summit/strptime-usage/+merge/215540
> Your team Summit Hackers is requested to review the proposed merge of
> lp:~vorlon/summit/strptime-usage into lp:summit.
>

Steve Langasek (vorlon) wrote :

On Sat, Apr 12, 2014 at 10:30:21PM -0000, José Antonio Rey wrote:
> I think you wanted to push this against lp:summit/production instead of lp:summit?

According to Michael, this is where it needs to be pushed.

José Antonio Rey (jose) wrote :

I was wondering because of the revision numbers. Also, the parent branch looks like production.

Michael Hall (mhall119) wrote :

When does the '%H:%M:%S' format get passed to this widget's decompress() method?

review: Needs Information

Unmerged revisions

224. By Steve Langasek on 2014-04-12

Make the custom DateTime widget nullable, like the upstream one is

223. By Steve Langasek on 2014-04-12

Apparently we can get this code path called with two different time formats; dunno why, but this addresses the problem at least for now

222. By Steve Langasek on 2014-04-12

Pass the right format string to strptime

I have no idea how this bug could have escaped notice for so long, but the
code is definitely unpacking a string in the wrong format. Fix a backtrace
when trying to submit registration forms for DebConf.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'summit/common/widgets.py'
2--- summit/common/widgets.py 2013-04-08 20:50:49 +0000
3+++ summit/common/widgets.py 2014-04-12 21:46:55 +0000
4@@ -59,7 +59,10 @@
5
6 def decompress(self, value):
7 if isinstance(value, str):
8- value = strptime(value, '%I:%M %p')
9+ try:
10+ value = strptime(value, '%H:%M:%S')
11+ except ValueError:
12+ value = strptime(value, '%I:%M %p')
13 hour = int(value.tm_hour)
14 minute = int(value.tm_min)
15 if hour < 12:
16@@ -78,6 +81,8 @@
17
18 def value_from_datadict(self, data, files, name):
19 value = super(TimeWidget, self).value_from_datadict(data, files, name)
20+ if value[0] == None:
21+ return None
22 t = strptime(
23 "%02d:%02d %s" % (
24 int(value[0]),
25
26=== modified file 'summit/version.py'
27--- summit/version.py 2013-08-28 11:38:34 +0000
28+++ summit/version.py 2014-04-12 21:46:55 +0000
29@@ -1,2 +1,2 @@
30-version = '1.2.14'
31-revno = '560'
32+version = '1.2.16'
33+revno = '221'

Subscribers

People subscribed via source and target branches