On Sep 18, 2009, at 4:14 PM, [email protected] wrote:
> We have a form with two grids. The left grid displays test batches,
> and the
> right grid displays the tubes in the test batches. We'd like to have a
> button change the values of a field on the tubes table (the child of
> the batch
> table) for just the rows that belong to the currently highlighted
> row in
> the batch table.
>
> Here's the code we came up with:
>
> dlg = dabo.ui.createForm("Invalidate.cdxml", show=True, parent=self)
> if dlg.Accepted:
> bizRuns = self.Form.getBizobj("runs")
> ThisRun = bizRuns.getFieldVal('run_no')
> bizTubes = self.Form.getBizobj("tubes")
> begOK = bizTubes.beginTransaction()
> bizTubes.replace('result',"Invalid",scope="tubes.run_no=ThisRun")
> cmtOK = bizTubes.commitTransaction()
If this were a parent-child relationship between batch and tubes,
there would be no need for a scope; the tubes bizobj should only
contain those records that "belong" to the parent, and it looks like
you want to replace all of them. But it appears that you have
something different going on here, if the tubes bizobj can contain
records unrelated to the current batch.
> The problem we're having is with the scope. The traceback says:
> "invalid syntax" pointing to the tubes.run_no=Thisrun line. What's
> proper syntax for the scope argument?
There are a couple of things wrong. First, since you are testing
equality, you need the double-equals, not the single equals. Second,
since the scope expression will be evaluated in a method in which the
name 'ThisRun' is most likely not defined, you need to supply the
actual value. Try using something like:
bizTubes.replace("result", "Invalid", scope="tubes.run_no==%s" %
ThisRun)
-- Ed Leafe
_______________________________________________
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]