storborg / pyramid_uniform

Form handling for Pyramid
Other
2 stars 2 forks source link

Offer forwards/backwards compatibility for old-style usage of WebHelpers2 select() #10

Closed storborg closed 9 years ago

storborg commented 9 years ago

The final release of WebHelpers2 changed the select() semantics for typical lists of (value, label). More info here: https://webhelpers2.readthedocs.org/en/latest/modules/html/tags.html#select-and-options-helpers

Evaluate making a rewrite layer which catches this usage, raises a DeprecationWarning, and converts to the new format.

Here's a quick example of how to convert the usage:

countries_by_code = [
    ('us', 'United States'),
    ('ca', 'Canada'),
    ('se', 'Sweden'),
    ('tr', 'Turkey'),
]

# before
from webhelpers.html.tags import *

select('country_code', 'ca', countries_by_code)

# after
from webhelpers2.html.tags import *

select('country_code', 'ca', Options([Option(label, value) for value, label in countries_by_code]))
storborg commented 9 years ago

Done in 440a30895704663fe75d1bffbe8e10fbf12b2a8c