On May 10, 2009, at 12:39 AM, Paul McNett wrote:

> Ed, can you explain why setting the crs.KeyField property earlier  
> would make all the
> difference?

        Easy: I looked to see where the calls to getFields() was coming from  
(hint to anyone doing similar debugging: dabo.logPoint() is your  
friend). They were coming from the dCursorMixin._setTable() setter:


def _setTable(self, table):
        self._table = self.AuxCursor._table = self.sqlManager._table = "%s" %  
table
        if table and not self._keyFieldSet:
                flds = self.getFields(table)
                if flds is None:
                        return
                # Get the PK field, if any
                try:
                        self._keyField = [fld[0] for fld in flds
                                        if fld[2] ][0]
                except IndexError:
                        pass


        If the key field wasn't set, the code would call getFields() in order  
to figure out the PK. By settting KeyField first, that first if block  
was never executed.

        The reason I haven't committed this quick fix is that I'm re-thinking  
a lot of stuff like this to try to find ways to eliminate this sort of  
fragility. When I see things like this, I don't think "Gee, that was a  
simple fix"; instead, I think that I've uncovered a weak design, and I  
want to make it more robust.


-- Ed Leafe




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

Reply via email to