#10541 closed defect (fixed)
ListOption seems to ignore/suppress 0
| Reported by: | Owned by: | Jun Omae | |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.1 |
| Component: | general | Version: | 0.11.6 |
| Severity: | major | Keywords: | config |
| Cc: | Branch: | ||
| Release Notes: |
|
||
| API Changes: | |||
| Internal Changes: | |||
Description (last modified by )
I'm trying to add a list of work days (days of the week) to TeamCalendar plugin. Near the top I do:
class TeamCalendar(Component): implements(INavigationContributor, IRequestHandler, IPermissionRequestor, ITemplateProvider) ... # Default work week. work_days = ListOption('team-calendar', 'work_days', [0, 1, 2, 3, 4], doc="Lists days of week that are worked. " + \ "Defaults to none. 0 is Monday.")
and later
self.env.log.debug('work_days: %s ' % self.work_days) timetable = {} current_date = from_date while current_date <= to_date: if current_date.weekday() in self.work_days:
The log does not show the 0, only 1..4. If I set the default to [99, 0, 1, 2, 3, 4], the log shows 99 but not 0 so it isn't the first element that's getting dropped.
Attachments (0)
Change History (8)
comment:1 by , 13 years ago
| Keywords: | config added |
|---|---|
| Milestone: | → 1.0.1 |
follow-up: 3 comment:2 by , 13 years ago
If we're not using filter(None, ), we could as well use a list comprehension here?
items = [v for v in items if v or v is not None etc.]
And for the test itself, in trunk we could use isinstance(v, numbers.Number) if we indeed switch to Python 2.6 as a base requirement.
comment:3 by , 13 years ago
Replying to cboos:
If we're not using
filter(None, ), we could as well use a list comprehension here?items = [v for v in items if v or v is not None etc.]
Oh, yes. Thanks ;-)
-
trac/config.py
455 455 else: 456 456 items = list(value) 457 457 if not keep_empty: 458 items = filter(None, items) 458 items = [v for v in items 459 if v or isinstance(v, (int, long, float))] 459 460 return items 460 461 461 462 def getpath(self, key, default=''):
I'll apply later.
comment:4 by , 13 years ago
| Release Notes: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
Fixed in [11478-11479].
comment:5 by , 13 years ago
| Owner: | set to |
|---|
comment:6 by , 13 years ago
comment:7 by , 11 years ago
| Reporter: | changed from to |
|---|
comment:8 by , 10 years ago
| Reporter: | changed from to |
|---|



Reproduced.
ListOptiondrops0 (int)and0.0 (float)from raw list as default value.Workaround is to specify string as default value.
If did fix this…
trac/config.py
trac/tests/config.py