#8763 closed defect (worksforme)
ListOption doesn't always work as expected
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | general | Version: | 0.11.5 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
ListOption
does not always unpack values. Given the example code:
class StyleMarkers(Component): """apply a static style to the markers""" implements(IMapMarkerStyle) styles = ListOption('geo', 'static_marker_style', '', "static styles to apply to markers") def style(self, ticket, req, **style): retval = {} import pdb; pdb.set_trace() for s in self.styles: key, value = s.split(':', 1) key = key.strip() value = value.strip() if key not in style: retval[key] = value return retval
in trac.ini
static_marker_style = fillOpacity: 0.3, graphicOpacity: 0.3, strokeOpacity: 0.3
However, upon hitting the pdb
, the values are not unpacked:
(Pdb) self.styles [u'fillOpacity: 0.3, graphicOpacity: 0.3, strokeOpacity: 0.3']
However, self.env.config.getlist
does work as expected:
(Pdb) self.env.config.getlist('geo', 'static_marker_style') [u'fillOpacity: 0.3', u'graphicOpacity: 0.3', u'strokeOpacity: 0.3']
I will use getlist
for now, but would love to see the API fixed properly so I didn't have to do work arounds. I've noticed this bug off and on. Not sure what the reason for it is or why it seems intermittent
Attachments (0)
Change History (3)
comment:1 by , 15 years ago
Milestone: | → 0.11.6 |
---|---|
Owner: | set to |
comment:2 by , 15 years ago
Milestone: | 0.11.6 |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
Be careful how you pass the docstring to the ListOption
. In your example, you're actually passing it as the sep=
argument, which is the list separator. You should use the following instead:
styles = ListOption('geo', 'static_marker_style', '', doc="static styles to apply to markers")
Note the doc=
.
comment:3 by , 15 years ago
Oh, and please use the MailingList or the IrcChannel for support questions ;-)
I'm working on the config module, so I'll look into this.