Carl Karsten wrote:
> Paul McNett wrote:
>> Carl Karsten wrote:
>>> Paul McNett wrote:
>>>> Ed Leafe wrote:
>>>>> On Jun 12, 2007, at 12:30 PM, Paul McNett wrote:
>>>>>
>>>>>> This isn't mediated through the form, even though 'self' is the form.
>>>>>   OK, then, explain the difference between a direct reference to the  
>>>>> bizobj, and constantly asking the form for the reference. How is that  
>>>>> "mediating"?
>>>> It is clear that I misunderstood this entire thread. However, to answer 
>>>> your question, take these two options:
>>>>
>>>> 1) grid.DataSource = biz  ## direct biz ref.
>>>>
>>>> --or--
>>>>
>>>> 2) grid.DataSource = biz.DataSource  ## indirect biz ref.
>>>>
>>>>
>>>> In #1, the grid will call biz.requery(), biz.moveToRowNum(), etc. In #2 
>>>> the grid will call form.requery(self.DataSource), 
>>>> form.moveToRowNum(self.DataSource), etc.
>>> huh?
>>>
>>> Not that I disagree, it is just surprising.  what code decides what to 
>>> call? 
>>> (biz.X vs form.X)
>> Ok, I need to clarify:
>>
>> 1) dGrid *never* calls requery().
>> 2) The *only* form method called if possible is moveToRowNum(): if the 
>> form is available and it has a bizobj with the grid's DataSource, *and* 
>> if the grid's DataSource isn't a direct bizobj reference.[1]
>>
>> The place where this decision happens:
>> http://svn.dabodev.com/trac/dabo/browser/trunk/dabo/ui/uiwx/dGrid.py#L3035
> 
> this line?
> 
> http://svn.dabodev.com/trac/dabo/browser/trunk/dabo/ui/uiwx/dGrid.py#L3062
>     if isinstance(self.Form, dabo.ui.dForm) and not 
> isinstance(self.DataSource, 
> dabo.biz.dBizobj):
>                          # run it through the form:
>     else:
>                               # run it through the bizobj directly:

Yes, that line.


>> When the cell is selected, the grid needs to tell the underlying bizobj 
>> what row to go to. In the first case (form mediates), the form will 
>> return False if the row couldn't be moved to. The grid refreshes, which 
>> places the cell selection on whatever row the bizobj reports it is on 
>> currently. In the second case (biz mediates), we trap the error and call 
>> grid.refresh().
> 
> ok, makes more sense now.

Good, glad to help.


> Another pondering: can this logic be used by something else other than a 
> grid? 

I suppose any control that displays more than one record, and has the 
concept of the active record. Currently, the only control that has that 
concept is dGrid.

> or something.  seems like a lot of code in one place, and a little bit 
> magical.

Most of that code is comment.

> what do you think of this:
> 
> add .moveToRowNumber() to bizobj,

Already exists in dBizobj.

> add .controller to grid
> at some point early on in the life of the grid, figure out what to store to 
> .controller, either self.Form or self.getBizobj()
> in grid._onGridCellSelected()  call .controller.moveToRowNumber()
> and tie up the lose ends, not everything in the current code is accounted for 
> :)
> 
> The idea is to isolate the magic - figure it out once, in a simpler block of 
> code.  and to make it easier to extend the current class without having to 
> cut/paste/modify grid._onGridCellSelected()
> 
> I don't advocate making this change now, more like if this code or code like 
> it 
> ever needs to be worked in the future.

I agree with the concept of isolating magic and not repeating complex 
bits of code. So as soon as we have another place that needs this, we'll 
abstract it.


-- 
pkm ~ http://paulmcnett.com


_______________________________________________
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/dabo-users/[EMAIL PROTECTED]

Reply via email to