On 3/12/12 4:34 PM, Ed Leafe wrote:
> On Mar 12, 2012, at 1:04 PM, Paul McNett wrote:
>
>> If you don't think this is horrible, I want to hear why:
>>
>> dabo/dabo/db/dCursorMixin.py
>> 2072 def moveToPK(self, pk):
>> 2073 """
>> 2074 Find the record with the passed primary key, and make it active.
>> 2075
>> 2076 If the record is not found, the position is set to the first record.
>> 2077 """
>> 2078 row, rec = self._getRecordByPk(pk, raiseRowNotFound=False)
>> 2079 if row is None:
>> 2080 row = 0
>> 2081 self.RowNumber = row
>
> I think that this is horrible. The very name of the method suggests
> that you should be supplying a valid PK. If it doesn't exist, it should raise
> a RowNotFoundException. The calling method should then decide how to handle
> an invalid PK.
The reason I didn't go any further was because I discovered a handful of other
methods that do essentially the same thing, in both dCursorMixin and dBizobj,
and I
was concerned about breaking existing code that relies on one or more of these.
moveToPK() has been there at least since revision 190 in April of 2004.
I think we need to unify the various methods that already exist. It seems that
the
code to expose publicly for both biz and cur should be:
def moveToPK(self, pk):
"""
Move the record pointer to the passed primary key value.
If the pk does not exist in the data set, raise RowNotFound.
"""
if self.locate(pk, self.KeyField):
return True
raise dExceptions.RowNotFound
Perhaps locate() is too general and there would be a more optimized way, I
haven't
looked. We also need a method for internal use that doesn't requery the
children, and
perhaps other things.
Paul
_______________________________________________
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]