Skip to content

ObjectSelect objects key, value changes to value, key after update #398

@MarcSkovMadsen

Description

@MarcSkovMadsen

My Pain

I'm trying to dynamically update the objects from which a user can select. But the behavior of param.ObjectSelector.objects is different before and after update.

$ python 'issue_object_selector.py'
Traceback (most recent call last):
  File "issue_object_selector.py", line 12, in <module>
    app.value=3
  File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 294, in _f
    instance_param.__set__(obj, val)
  File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 296, in _f
    return f(self, obj, val)
  File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\parameterized.py", line 823, in __set__
    self._validate(val)
  File "C:\Users\masma\source\repos\orsteddcsmarketsanalytics\api\.venv\lib\site-packages\param\__init__.py", line 1242, in _validate
    "valid options include %s"%(val,attrib_name, items))
ValueError: 3 not in Parameter value's list of possible objects, valid options include [Third, Fourth]
import param
OBJECTS_ALL = {"First":1 , "Second": 2}


class App(param.Parameterized):
    value = param.ObjectSelector(default=1, objects=OBJECTS_ALL)

app=App()
app.value=2

app.param.value.objects = {"Third": 3, "Fourth": 4}
app.value=3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions