You don't need to do what you're doing :) Just use request.getall('perm')
, which will always return a list.
Several attributes of a WebOb request are “multidict”; structures (such as request.GET, request.POST, and request.params). A multidict is a dictionary where a key can have multiple values. The quintessential example is a query string like ?pref=red&pref=blue; the pref variable has two values: red and blue.
In a multidict, when you do request.GET['pref'] you’ll get back only 'blue' (the last value of pref). Sometimes returning a string, and sometimes returning a list, is the cause of frequent exceptions. If you want all the values back, use request.GET.getall('pref'). If you want to be sure there is one and only one value, use request.GET.getone('pref'), which will raise an exception if there is zero or more than one value for pref.
http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/webob.html
(you should also not try to modify the values of request.params
, which is read-only. Use a separate dict instead.)