Edgewall Software

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#8763 closed defect (worksforme)

ListOption doesn't always work as expected

Reported by: Jeff Hammel <jhammel@…> Owned by: Remy Blank
Priority: normal Milestone:
Component: general Version: 0.11.5
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


ListOption does not always unpack values. Given the example code:

class StyleMarkers(Component):
    """apply a static style to the markers"""


    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 Remy Blank, 13 years ago

Milestone: 0.11.6
Owner: set to Remy Blank

I'm working on the config module, so I'll look into this.

comment:2 by Remy Blank, 13 years ago

Milestone: 0.11.6
Resolution: worksforme
Status: newclosed

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 Remy Blank, 13 years ago

Oh, and please use the MailingList or the IrcChannel for support questions ;-)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.