Paul McNett wrote:
>    File "/home/pmcnett/ss/biz/ProductionOrderOpenings.py", line 99, in 
> set_hor_dividers
>      bizHorDividers.sort("position")
>    File "/home/pmcnett/dabo/dabo/biz/dBizobj.py", line 891, in sort
>      self._CurrentCursor.sort(col, ord, caseSensitive)
>    File "/home/pmcnett/dabo/dabo/db/dCursorMixin.py", line 476, in sort
>      raise dException.NoRecordsException, _("No rows to sort.")
> dabo.dException.NoRecordsException: No rows to sort.
> 
> This would be easy to catch and handle in my code, but is this an 
> important exception to raise? I mean, the expected behavior when sorting 
> an empty cursor would be to still have an empty cursor. It seems 
> reasonable not to have to handle this exception.
> 
> Thoughts?

Here's my suggested change:

Index: dabo/db/dCursorMixin.py
===================================================================
--- dabo/db/dCursorMixin.py     (revision 3940)
+++ dabo/db/dCursorMixin.py     (working copy)
@@ -471,12 +471,8 @@
                 currOrd = self.sortOrder
                 currCase = self.sortCase

-               # Check to make sure that we have data
-               if self.RowCount < 1:
-                       raise dException.NoRecordsException, _("No rows 
to sort.")
-
                 # Make sure that the specified column is a column in 
the result set
-               if not self._records[0].has_key(col) and not 
self.VirtualFields.has_key(col):
+               if not [True for t in self.DataStructure if t[0] == col] 
  and not self.VirtualFields.has_key(col):
                         raise dException.dException, _("Invalid column 
specified for sort: ") + col

                 newCol = col
@@ -523,7 +519,7 @@
                 the data according to the request.
                 """
                 kf = self.KeyField
-               if not kf:
+               if not kf or not self.RowCount:
                         return

                 if not self.__unsortedRows:


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

Reply via email to