Author: Miguel Lopes
Posted: 2009-07-26 18:01:54 Link
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
Author: Ed Leafe
Posted: 2009-07-26 18:30:21 Link
On Jul 26, 2009, at 5:01 PM, Miguel Lopes wrote:
> 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.
This is an issue that we've come across several times, and have never
come up with an acceptable resolution. Basically, the list must be
populated before anything else happens to it, but the data binding
events try to set values in the list before the list is populated, and
so we get that error.
Paul, I'm wondering - could we trap this particular error, set a flag
in the object, and then add this to the end of the event loop using a
setAfter call? The flag would enable us to avoid infinite loops if an
attempt to set an invalid value was made, but would avoid erroring out
because of the wrong event order.
-- Ed Leafe
Author: Miguel Lopes
Posted: 2009-07-26 18:40:12 Link
On Sun, Jul 26, 2009 at 11:30 PM, Ed Leafe<ed@leafe.com> wrote:
> On Jul 26, 2009, at 5:01 PM, Miguel Lopes wrote:
>
>> 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.
>
>
> =A0 =A0 =A0 =A0This is an issue that we've come across several times, and=
have never
> come up with an acceptable resolution. Basically, the list must be
> populated before anything else happens to it, but the data binding
> events try to set values in the list before the list is populated, and
> so we get that error.
>
> =A0 =A0 =A0 =A0Paul, I'm wondering - could we trap this particular error,=
set a flag
> in the object, and then add this to the end of the event loop using a
> setAfter call? The flag would enable us to avoid infinite loops if an
> attempt to set an invalid value was made, but would avoid erroring out
> because of the wrong event order.
>
>
> -- Ed Leafe
Txs for the clarification Ed.
Miguel
Author: Paul McNett
Posted: 2009-07-27 00:30:17 Link
Ed Leafe wrote:
> Paul, I'm wondering - could we trap this particular error, set a flag
> in the object, and then add this to the end of the event loop using a
> setAfter call? The flag would enable us to avoid infinite loops if an
> attempt to set an invalid value was made, but would avoid erroring out
> because of the wrong event order.
The problem stems from setting listbox.Value before listbox.Choices and
listbox.Keys are set?
We've seen similar patterns before (certain properties are better set
before/after certain other ones), in which case I think we need to
define some protocol to put in dPemMixin to determine which properties
to set in which order.
Then in each defined class (dListBox.py, etc.) we could define these needs.
Off the top of my head:
class dListBox.py(...)
...
_prop_order = ["Choices", "Keys", "Value"]
and any props not listed in the _prop_order attribute could get set
before, after, or interspersed with the _prop_order props, but the one
guaranteed thing would be that Value would get set after Keys, and Keys
would get set after Choices.
Would something like this fix this issue?
Paul
Author: Ed Leafe
Posted: 2009-07-27 01:03:57 Link
On Jul 26, 2009, at 11:30 PM, Paul McNett wrote:
> The problem stems from setting listbox.Value before listbox.Choices
> and
> listbox.Keys are set?
I think so, but I'm not sure that this is the cause in all the cases
that have been reported. But it does seem that in many cases the code
is populating the list, but they are still getting the 'value not in
list' error.
> Off the top of my head:
>
> class dListBox.py(...)
> ...
> _prop_order = ["Choices", "Keys", "Value"]
>
> and any props not listed in the _prop_order attribute could get set
> before, after, or interspersed with the _prop_order props, but the one
> guaranteed thing would be that Value would get set after Keys, and
> Keys
> would get set after Choices.
>
> Would something like this fix this issue?
I don't think it would be that simple, since we also have DataSource
and DataField, which indirectly set Value, too. That's why I thought
handling the first error with a delay, and only if it fails in the
setAfter() attempt do we treat it like an actual error.
-- Ed Leafe
Author: Paul McNett
Posted: 2009-07-27 01:21:48 Link
Ed Leafe wrote:
> On Jul 26, 2009, at 11:30 PM, Paul McNett wrote:
>
>> The problem stems from setting listbox.Value before listbox.Choices
>> and
>> listbox.Keys are set?
>
>
> I think so, but I'm not sure that this is the cause in all the cases
> that have been reported. But it does seem that in many cases the code
> is populating the list, but they are still getting the 'value not in
> list' error.
>
>> Off the top of my head:
>>
>> class dListBox.py(...)
>> ...
>> _prop_order = ["Choices", "Keys", "Value"]
>>
>> and any props not listed in the _prop_order attribute could get set
>> before, after, or interspersed with the _prop_order props, but the one
>> guaranteed thing would be that Value would get set after Keys, and
>> Keys
>> would get set after Choices.
>>
>> Would something like this fix this issue?
>
>
> I don't think it would be that simple, since we also have DataSource
> and DataField, which indirectly set Value, too. That's why I thought
> handling the first error with a delay, and only if it fails in the
> setAfter() attempt do we treat it like an actual error.
Well, it could be:
_prop_order = ["Choices", "Keys", "DataSource", "DataField", "Value"]
However, your idea sounds easier to implement. Want to give it a go?
Paul
Author: Miguel Lopes
Posted: 2009-07-27 07:38:05 Link
On Mon, Jul 27, 2009 at 5:30 AM, Paul McNett<p@ulmcnett.com> wrote:
> Ed Leafe wrote:
>> =A0 =A0 =A0 Paul, I'm wondering - could we trap this particular error, s=
et a flag
>> in the object, and then add this to the end of the event loop using a
>> setAfter call? The flag would enable us to avoid infinite loops if an
>> attempt to set an invalid value was made, but would avoid erroring out
>> because of the wrong event order.
>
> The problem stems from setting listbox.Value before listbox.Choices and
> listbox.Keys are set?
No. I have the problem even considering / respecting that.
This case maybe special because the form is loaded from a cdxml file.
Note that properties are not being set in the class designer (as per
my email above).
In this case dropdownList properties are being set in the afterInitAll
cdxml form method. The code is:
def afterInitAll(self):
_valueListProvider =3D self.Application.getAppInfo('valueListProvider')
vlKeys, vlChoices =3D _valueListProvider.getKeysAndChoices('contact_title'=
)
dropDown =3D self.getObjectByRegID("dlTitle")
dropDown.DataSource=3D"contact"
dropDown.DataField=3D"title_id"
dropDown.Keys =3D vlKeys
dropDown.Choices =3D vlChoices
dropDown.ValueMode=3D"Key" # if both commented runs ok - but not
in 'key' valueMode
dropDown.Value =3D vlKeys[0] # if both commented runs ok - but
not in 'key' valueMode
I started to think the problem might not be order, but comming from
when the bizobj. So I made sure the bizobj is previously created (in
the createBizobj cdxml form method). This had no success.
Miguel
Author: Paul McNett
Posted: 2009-07-27 09:05:31 Link
Miguel Lopes wrote:
> This case maybe special because the form is loaded from a cdxml file.
> Note that properties are not being set in the class designer (as per
> my email above).
>
> In this case dropdownList properties are being set in the afterInitAll
> cdxml form method. The code is:
>
> def afterInitAll(self):
> _valueListProvider = self.Application.getAppInfo('valueListProvider')
> vlKeys, vlChoices = _valueListProvider.getKeysAndChoices('contact_title')
> dropDown = self.getObjectByRegID("dlTitle")
> dropDown.DataSource="contact"
> dropDown.DataField="title_id"
> dropDown.Keys = vlKeys
> dropDown.Choices = vlChoices
> dropDown.ValueMode="Key" # if both commented runs ok - but not
> in 'key' valueMode
> dropDown.Value = vlKeys[0] # if both commented runs ok - but
> not in 'key' valueMode
What happens with:
def afterInitAll(self):
...
dropDown.Keys = vlKeys
dropDown.Choices = vlChoices
dropDown.ValueMode = "key"
print self.getBizobj("contact")
dropDown.DataSource = "contact"
dropDown.DataField = "title_id"
print "choices", dropDown.Choices
print "keys", dropDown.Keys
After typing the above I just re-read your original post, and see that
the offending line is where you set dropDown.Value = vlKeys[0]. You
generally don't want to do that, because the Value is coming from the
bizobj and you are setting it to an arbitrary value which would get
saved to the bizobj.
However, you should be able to do that if you really want to, if the key
is present in the choices. Otherwise, you'll get the error you
originally reported. So, please still run with the above changes and
let's see what the choices and keys are.
Paul
Author: Miguel Lopes
Posted: 2009-07-27 09:38:35 Link
On Mon, Jul 27, 2009 at 2:05 PM, Paul McNett<p@ulmcnett.com> wrote:
> Miguel Lopes wrote:
>> This case maybe special because the form is loaded from a cdxml file.
>> Note that properties are not being set in the class designer (as per
>> my email above).
>>
>> In this case dropdownList properties are being set in the afterInitAll
>> cdxml form method. The code is:
>>
>> def afterInitAll(self):
>> =A0 =A0 =A0 _valueListProvider =3D self.Application.getAppInfo('valueLis=
tProvider')
>> =A0 =A0 =A0 vlKeys, vlChoices =3D _valueListProvider.getKeysAndChoices('=
contact_title')
>> =A0 =A0 =A0 dropDown =3D self.getObjectByRegID("dlTitle")
>> =A0 =A0 =A0 dropDown.DataSource=3D"contact"
>> =A0 =A0 =A0 dropDown.DataField=3D"title_id"
>> =A0 =A0 =A0 dropDown.Keys =3D vlKeys
>> =A0 =A0 =A0 dropDown.Choices =3D vlChoices
>> =A0 =A0 =A0 dropDown.ValueMode=3D"Key" =A0 =A0 =A0# if both commented ru=
ns ok - but not
>> in 'key' valueMode
>> =A0 =A0 =A0 dropDown.Value =3D vlKeys[0] =A0 =A0 =A0 # if both commented=
runs ok - but
>> not in 'key' valueMode
>
> What happens with:
>
> def afterInitAll(self):
> =A0 =A0 =A0 =A0...
> =A0 =A0 =A0 =A0dropDown.Keys =3D vlKeys
> =A0 =A0 =A0 =A0dropDown.Choices =3D vlChoices
> =A0 =A0 =A0 =A0dropDown.ValueMode =3D "key"
> =A0 =A0 =A0 =A0print self.getBizobj("contact")
> =A0 =A0 =A0 =A0dropDown.DataSource =3D "contact"
> =A0 =A0 =A0 =A0dropDown.DataField =3D "title_id"
> =A0 =A0 =A0 =A0print "choices", dropDown.Choices
> =A0 =A0 =A0 =A0print "keys", dropDown.Keys
>
>
> After typing the above I just re-read your original post, and see that
> the offending line is where you set dropDown.Value =3D vlKeys[0]. You
> generally don't want to do that, because the Value is coming from the
> bizobj and you are setting it to an arbitrary value which would get
> saved to the bizobj.
The dropDown.ValueMode =3D "key" has also been an offending line from
the beginning.
> However, you should be able to do that if you really want to, if the key
> is present in the choices. Otherwise, you'll get the error you
> originally reported. So, please still run with the above changes and
> let's see what the choices and keys are.
>
> Paul
>
The print is:
<biz.ContactBizobj.ContactBizobj (baseclass dabo.biz.dBizobj, id:439330288)=
>
choices [u'Sr.', u'Sr.\xaa', u'Arq.', u'Arq.\xaa', u'Eng.',
u'Eng.\xaa', u'Dr.', u'Dr.\xaa']
keys [25, 24, 23, 22, 21, 20, 19, 18]
The traceback is the same as before:
Traceback (most recent call last):
File "//usr/local/lib/wxPython-unicode-2.8.9.2/lib/python2.5/site-package=
s/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-package=
s/wx-2.8-mac-unicode/wx/_core.py",
line 14676, in Notify
self.result =3D self.callable(*self.args, **self.kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-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/sit=
e-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/sit=
e-packages/dabo/ui/uiwx/dPemMixin.py",
line 949, in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args, **kwa=
rgs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-packages/dabo/lib/eventMixin.py",
line 93, in raiseEvent
bindingFunction(event)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-packages/dabo/ui/uiwx/dPemMixin.py",
line 1225, in __onUpdate
self.update()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-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/sit=
e-packages/dabo/ui/uiwx/dPemMixin.py",
line 949, in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args, **kwa=
rgs)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-packages/dabo/lib/eventMixin.py",
line 93, in raiseEvent
bindingFunction(event)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-packages/dabo/ui/uiwx/dPemMixin.py",
line 1225, in __onUpdate
self.update()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-packages/dabo/ui/dDataControlMixinBase.py",
line 97, in update
self.__dataUpdate()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-packages/dabo/ui/dDataControlMixinBase.py",
line 114, in __dataUpdate
self.Value =3D src.getFieldVal(self.DataField)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-packages/dabo/ui/uiwx/dControlItemMixin.py",
line 380, in _setValue
self.KeyValue =3D value
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sit=
e-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]
If we run your code without the line:
dropDown.ValueMode =3D "key"
Then there is no exception raise. But, as expected, the value of the
"title_id" field does not get recorded to the db, because it is a
string, not an integer. So there is something wrong with setting
ValueMode.
HTH,
Miguel
Author: Paul McNett
Posted: 2009-07-27 09:52:16 Link
Miguel Lopes wrote:
> On Mon, Jul 27, 2009 at 2:05 PM, Paul McNett<p@ulmcnett.com> wrote:
>> Miguel Lopes wrote:
>>> This case maybe special because the form is loaded from a cdxml file.
>>> Note that properties are not being set in the class designer (as per
>>> my email above).
>>>
>>> In this case dropdownList properties are being set in the afterInitAll
>>> cdxml form method. The code is:
>>>
>>> def afterInitAll(self):
>>> _valueListProvider = self.Application.getAppInfo('valueListProvider')
>>> vlKeys, vlChoices = _valueListProvider.getKeysAndChoices('contact_title')
>>> dropDown = self.getObjectByRegID("dlTitle")
>>> dropDown.DataSource="contact"
>>> dropDown.DataField="title_id"
>>> dropDown.Keys = vlKeys
>>> dropDown.Choices = vlChoices
>>> dropDown.ValueMode="Key" # if both commented runs ok - but not
>>> in 'key' valueMode
>>> dropDown.Value = vlKeys[0] # if both commented runs ok - but
>>> not in 'key' valueMode
>> What happens with:
>>
>> def afterInitAll(self):
>> ...
>> dropDown.Keys = vlKeys
>> dropDown.Choices = vlChoices
>> dropDown.ValueMode = "key"
>> print self.getBizobj("contact")
>> dropDown.DataSource = "contact"
>> dropDown.DataField = "title_id"
>> print "choices", dropDown.Choices
>> print "keys", dropDown.Keys
>>
>>
>> After typing the above I just re-read your original post, and see that
>> the offending line is where you set dropDown.Value = vlKeys[0]. You
>> generally don't want to do that, because the Value is coming from the
>> bizobj and you are setting it to an arbitrary value which would get
>> saved to the bizobj.
>
> The dropDown.ValueMode = "key" has also been an offending line from
> the beginning.
>
>> However, you should be able to do that if you really want to, if the key
>> is present in the choices. Otherwise, you'll get the error you
>> originally reported. So, please still run with the above changes and
>> let's see what the choices and keys are.
>>
>> Paul
>>
>
> The print is:
> <biz.ContactBizobj.ContactBizobj (baseclass dabo.biz.dBizobj, id:439330288)>
> choices [u'Sr.', u'Sr.\xaa', u'Arq.', u'Arq.\xaa', u'Eng.',
> u'Eng.\xaa', u'Dr.', u'Dr.\xaa']
> keys [25, 24, 23, 22, 21, 20, 19, 18]
>
> The traceback is the same as before:
> 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]
>
> If we run your code without the line:
> dropDown.ValueMode = "key"
>
> Then there is no exception raise. But, as expected, the value of the
> "title_id" field does not get recorded to the db, because it is a
> string, not an integer. So there is something wrong with setting
> ValueMode.
The offending line(s) aren't directly causing the traceback. The problem
appears to be that the bizobj reports that the value of contact.title_id
is 0.
Do a:
dropDown.Choices.append("---None---")
dropDown.Keys.append(0)
and you should see the traceback disappear.
You probably need to set a sensible default value for title_id in your
bizobj (one that is one of the choices presented in the list).
Paul