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: > > > 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(). > > [1] See latest commit which fixes this > ok, makes more sense now. Another pondering: can this logic be used by something else other than a grid? or something. seems like a lot of code in one place, and a little bit magical. what do you think of this: add .moveToRowNumber() to bizobj, 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. Carl K _______________________________________________ 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]
