[dabo-users] Setting DropdownList.Value exception

Author: Miguel Lopes

Posted: 2009-07-26 at 18:01:54

I can't seem to get arround an exception I'm getting.

I'm opening a very simple cdxml form. There is a dropdownlist in it

with the following definition:

<dDropdownList sizerInfo="{'RowSpan': 1, 'ColSpan': 1, 'Proportion':

0, 'HAlign': 'Left'}" RegID="dlTitle" Name="dDropdownList1"

rowColPos="(2, 1)" designerClass="controlMix" DataSource="contact"

DataField="title_id"></dDropdownList>

I choosed to set the remaining properties after instantiation, because

I was already getting this exception. But the changes did not help.

My afterInitAll method (on the form I'm opening is):

def afterInitAll(self):

_valueListProvider = self.Application.getAppInfo('valueListProvider')

vlKeys, vlChoices = _valueListProvider.getKeysAndChoices('contact_title')

dropDown = self.getObjectByRegID("dlTitle")

dropDown.ValueMode="Key"

dropDown.Keys = vlKeys

dropDown.Choices = vlChoices

dropDown.Value = vlKeys[0] # Ofending line

And:

Traceback (most recent call last):

File "//usr/local/lib/wxPython-unicode-2.8.9.2/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_misc.py",

line 1342, in Notify

self.notify()

File "//usr/local/lib/wxPython-unicode-2.8.9.2/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_core.py",

line 14676, in Notify

self.result = self.callable(*self.args, **self.kwargs)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dForm.py",

line 123, in __update

super(BaseForm, self).update()

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",

line 1244, in update

self.raiseEvent(dEvents.Update)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",

line 949, in raiseEvent

super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args, **kwargs)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/lib/eventMixin.py",

line 93, in raiseEvent

bindingFunction(event)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",

line 1225, in __onUpdate

self.update()

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",

line 1244, in update

self.raiseEvent(dEvents.Update)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",

line 949, in raiseEvent

super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args, **kwargs)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/lib/eventMixin.py",

line 93, in raiseEvent

bindingFunction(event)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",

line 1225, in __onUpdate

self.update()

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/dDataControlMixinBase.py",

line 97, in update

self.__dataUpdate()

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/dDataControlMixinBase.py",

line 114, in __dataUpdate

self.Value = src.getFieldVal(self.DataField)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dControlItemMixin.py",

line 380, in _setValue

self.KeyValue = value

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dControlItemMixin.py",

line 239, in _setKeyValue

raise ValueError(_("Trying to set %s.Value to these invalid

selections: %s") % (self.Name, invalidSelections))

ValueError: Trying to set dDropdownList1.Value to these invalid selections: [0]

To get around this I'll code the form by hand, which I expect will

raise no issues. But I have the feeling there is a bug lurking here.

Best,

Miguel

©2009 Miguel Lopes