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.
>

Ed, You are correct, in this case, what we want to do is change the value of a 
field in the child grid for the currently highlighted record in the parent 
grid. 

So, from what you're saying, we could use the child relationship to change the 
appropriate records.

We tried:

??bizRuns = self.Form.getBizobj("runs")
??begOK = bizRuns.beginTransaction()
??bizRuns.replace("tubes.result","Invalid")
??cmtOK = bizRuns.commitTransaction()
??if not cmtOK:
???rbk = bizRuns.rollbackTransaction()
???dabo.ui.info("Save failed")
??dlg.close()
??self.Form.requery()


We get no errors, but the replace has no effect. 

Any clues?


>> 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


Ed, we tried this with our original code. We're getting the error:

 ? File "c:\python25\lib\site-packages\Dabo-0.9.2-py2.5.egg\dabo\db\dDataSet.py"
?line 119, in replace
??? if eval(scope):
? File "<string>", line 1, in <module>
   NameError: name 'tubes' is not defined

When we changed simply "run_no==%s" % ThisRun, we got the error:

   NameError: name 'run_no' is not defined

So, how do we refer to the field in the table that gets its value replaced?

Thanks, 

Jonathan



--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
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