Miguel Lopes wrote:
> On Mon, Jul 27, 2009 at 2:52 PM, Paul McNett<[email protected]> wrote:
>> 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.
> 
> Then somehow the bizobj is setting the contact.title_id to 0 even
> though there is no default value set in the bizobj (nor the db for
> that matter).

Let's take a look. Put the following in the code snippet we've been 
working with (I believe afterInitAll() of the form):

biz = self.getBizobj("contact")
ds = biz.getDataSet()
for idx, row in enumerate(ds):
   print "record: %s" % idx, "title_id:", row["title_id"]


>> Do a:
>>
>> dropDown.Choices.append("---None---")
>> dropDown.Keys.append(0)
>>
>> and you should see the traceback disappear.
> 
> This works as expected.
> 
>> 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).
> 
> That worked (even without the presence of the 0 Key).

What worked? Setting a biz.DefaultValues["title_id"] = 0 ?


> But seems to me that the bizobj (perhaps more accurately it is the
> control) should not try to get a default value from the bizobj if
> there is none.

It isn't that the control is trying to get a default value from the 
bizobj. The control is simply trying to get the value of the field from 
the bizobj. If the field value isn't present in the list of choices, the 
error occurs.

I really think this is sensible behavior: it is an exceptional case if 
the dropdown isn't displaying a possible choice. You as the developer 
want the exception so you can track down the base cause and fix it.

The alternative would be to ignore this error and continue on as if 
everything were just fine, and you as the developer may never realize 
there's a problem.

"Errors should never pass silently." from The Zen of Python

Unfortunately, the next line in the Zen is "Unless explicitly silenced." 
but I can't offer that as a workaround because of the way the update 
mechanism works (we use a callAfter() so you can't just override 
update() and put in a try/except block).

Hopefully this discussion is helpful!

Paul


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to