[Dev] Re: revision 9520 breaks functional test TestDeleteCollection

Alec Flett alecf at osafoundation.org
Wed Feb 15 11:32:42 PST 2006


doh! thanks. working on it now...

John Anderson wrote:
> Hi Alecf:
>
> It looks like your recent revision 9520 broke the functional test 
> TestDeleteCollection
>
> John
>
> -------- Original Message --------
> Return-Path: 	<commits-bounces at osafoundation.org>
> X-Original-To: 	john at osafoundation.org
> Delivered-To: 	john at osafoundation.org
> Received: 	from leilani.osafoundation.org (leilani.osafoundation.org 
> [127.0.0.1]) by leilani.osafoundation.org (Postfix) with ESMTP id 
> 3B2FE7F6B8; Wed, 15 Feb 2006 08:16:14 -0800 (PST)
> X-Original-To: 	commits at osafoundation.org
> Delivered-To: 	commits at osafoundation.org
> Received: 	from laweleka.osafoundation.org (laweleka.osafoundation.org 
> [204.152.186.98]) by leilani.osafoundation.org (Postfix) with ESMTP id 
> DBBBD7F6B8 for <commits at osafoundation.org>; Wed, 15 Feb 2006 08:16:12 
> -0800 (PST)
> Received: 	from localhost (localhost [127.0.0.1]) by 
> laweleka.osafoundation.org (Postfix) with ESMTP id CC30E1422A9 for 
> <commits at osafoundation.org>; Wed, 15 Feb 2006 08:16:12 -0800 (PST)
> Received: 	from laweleka.osafoundation.org ([127.0.0.1]) by localhost 
> (laweleka.osafoundation.org [127.0.0.1]) (amavisd-new, port 10024) 
> with ESMTP id 26372-03 for <commits at osafoundation.org>; Wed, 15 Feb 
> 2006 08:16:12 -0800 (PST)
> Received: 	from tutu.osafoundation.org (tutu.osafoundation.org 
> [204.152.186.96]) by laweleka.osafoundation.org (Postfix) with ESMTP 
> id 948D81422A8 for <commits at osafoundation.org>; Wed, 15 Feb 2006 
> 08:16:12 -0800 (PST)
> Received: 	by tutu.osafoundation.org (Postfix, from userid 575) id 
> 7E78AF100D; Wed, 15 Feb 2006 08:16:12 -0800 (PST)
> MIME-Version: 	1.0
> To: 	commits at osafoundation.org
> Subject: 	[commits] (alecf) [9520] table code cleanup - consolidate 
> the code that maps table row selection into a set of selection ranges 
> into one function (RowRangeToIndexRange) and clean up code to use it
> X-Mailer: 	SVN::Notify 2.46: http://search.cpan.org/dist/SVN-Notify/
> Message-Id: 	<20060215161612.7E78AF100D at tutu.osafoundation.org>
> Date: 	Wed, 15 Feb 2006 08:16:12 -0800 (PST)
> X-Virus-Scanned: 	by amavisd-new and clamav at osafoundation.org
> X-Spam-Status: 	No, hits=1.4 tagged_above=-50.0 required=4.0 
> tests=AWL, HTML_40_50, HTML_MESSAGE, MIME_HTML_ONLY, NO_REAL_NAME
> X-Spam-Level: 	*
> From: 	commits at osafoundation.org
> X-BeenThere: 	commits at osafoundation.org
> X-Mailman-Version: 	2.1.5
> Precedence: 	list
> Reply-To: 	dev at osafoundation.org
> List-Id: 	OSAF Chandler Checkins <commits.osafoundation.org>
> List-Unsubscribe: 
> <http://lists.osafoundation.org/mailman/listinfo/commits>, 
> <mailto:commits-request at osafoundation.org?subject=unsubscribe>
> List-Archive: 	<http://lists.osafoundation.org/pipermail/commits>
> List-Post: 	<mailto:commits at osafoundation.org>
> List-Help: 	<mailto:commits-request at osafoundation.org?subject=help>
> List-Subscribe: 
> <http://lists.osafoundation.org/mailman/listinfo/commits>, 
> <mailto:commits-request at osafoundation.org?subject=subscribe>
> Content-Type: 	multipart/mixed; boundary="===============0412368944=="
> Mime-version: 	1.0
> Sender: 	commits-bounces at osafoundation.org
> Errors-To: 	commits-bounces at osafoundation.org
>
>
>
> Revision
>     9520 <http://viewcvs.osafoundation.org/chandler?view=rev&rev=9520>
> Author
>     alecf
> Date
>     2006-02-15 08:16:10 -0800 (Wed, 15 Feb 2006)
>
>
>       Log Message
>
> table code cleanup - consolidate the code that maps table row 
> selection into a set of selection ranges into one function 
> (RowRangeToIndexRange) and clean up code to use it
>
>
>       Modified Paths
>
>     * trunk/chandler/parcels/osaf/framework/blocks/Table.py
>       <#trunkchandlerparcelsosafframeworkblocksTablepy>
>
>
>       Diff
>
>
>         Modified:
>         trunk/chandler/parcels/osaf/framework/blocks/Table.py (9519 =>
>         9520)
>
> --- trunk/chandler/parcels/osaf/framework/blocks/Table.py	2006-02-15 06:19:26 UTC (rev 9519)
> +++ trunk/chandler/parcels/osaf/framework/blocks/Table.py	2006-02-15 16:16:10 UTC (rev 9520)
> @@ -199,39 +199,20 @@
>              # changes to the selection
>              blockItem.stopNotificationDirt()
>              try:
> -                # Extact the ranges from the grid using the top left
> -                # block of the selection and thr bottom right block of
> -                # the selection. Then assign the selected ranges to
> -                # the content's selection
> +                # map row ranges to index ranges 
>                  contents = self.blockItem.contents
>                  contents.setSelectionRanges ([])
> -                topLeftList = self.GetSelectionBlockTopLeft()
> -                bottomRightList = self.GetSelectionBlockBottomRight()
> -                for ((topLeftRow, topLeftColumn),
> -                     (bottomRightRow, bottomRightColumn)) in zip(topLeftList,
> -                                                                 bottomRightList):
> -                    indexStart = self.RowToIndex(topLeftRow)
> -                    indexEnd = self.RowToIndex(bottomRightRow)
> +                firstItemIndex = -1
> +                for indexStart, indexEnd in self.SelectedIndexRanges():
>  
> -                    # this is the ugly case where the user "selects" a
> -                    # section. It would be nice to avoid this case
> -                    # alltogether by making table sections
> -                    # un-selectable.
> -                    if -1 not in (indexStart, indexEnd):
> -                        contents.addSelectionRange ((indexStart, indexEnd))
> -               
> -                topLeftList.sort()
> +                    # We'll need the first selected index later..
> +                    if firstItemIndex == -1 or firstItemIndex > indexStart:
> +                        firstItemIndex = indexStart
> +                        
> +                    contents.addSelectionRange ((indexStart, indexEnd))
>                  item = None
> -                try:
> -                    (row, column) = topLeftList [0]
> -                except IndexError:
> -                    pass
> -                else:
> -                    itemIndex = self.RowToIndex(row)
> -                    if itemIndex != -1:
> -                        item = blockItem.contents [itemIndex]
> -                    else:
> -                        blockItem.PostSelectItems([])
> +                if firstItemIndex != -1:
> +                    item = blockItem.contents[firstItemIndex]
>      
>                  if item is not blockItem.selectedItemToView:
>                      blockItem.selectedItemToView = item
> @@ -448,6 +429,37 @@
>          self.blockItem.postEventByName("SelectItemsBroadcast",
>                                         {'items':[item]})
>  
> +    def SelectedIndexRanges(self):
> +        """
> +        Uses RowRangeToIndexRange to convert the selected rows to
> +        selected indexes
> +        """
> +        # filter out columns from grid selection
> +        topLeftList = self.GetSelectionBlockTopLeft()
> +        bottomRightList = self.GetSelectionBlockBottomRight()
> +        selectedRows = ((row1, row2) for ((row1, col1), (row2, col2)) in
> +                zip(topLeftList, bottomRightList))
> +        
> +        return self.RowRangeToIndexRange(selectedRows)
> +
> +    def RowRangeToIndexRange(self, rowRanges):
> +        """
> +        Given a list of row ranges, [(a,b), (c,d), ...], generate
> +        corresponding index ranges [(w,x), (y, z),..]
> +        """
> +        
> +        for (topRow, bottomRow) in rowRanges:
> +            indexStart = self.RowToIndex(topRow)
> +            indexEnd = self.RowToIndex(bottomRow)
> +
> +            # this is the ugly case where the user "selects" a
> +            # section. It would be nice to avoid this case
> +            # alltogether by making table sections
> +            # un-selectable.
> +            if -1 not in (indexStart, indexEnd):
> +                yield (indexStart, indexEnd)
> +        
> +
>      def DeleteSelection (self, DeleteItemCallback=None, *args, **kwargs):
>          def DefaultCallback(item, collection=self.blockItem.contents):
>              collection.remove(item)
> @@ -463,14 +475,10 @@
>          """
>          self.ClearSelection()
>          
> +        selectionRanges = []
>          # build up a list of selection ranges [[tl1, br1], [tl2, br2]]
> -        selectionRanges = []
> -        for topLeftRow,topLeftColumn in topLeftList:
> -            for bottomRightRow,bottomRightColumn in bottomRightList:
> -                indexStart = self.RowToIndex(topLeftRow)
> -                indexEnd = self.RowToIndex(bottomRightRow)
> -                if -1 not in (indexStart, indexEnd):
> -                    selectionRanges.append ([indexStart, indexEnd])
> +        for indexStart, indexEnd in self.SelectedIndexRanges():
> +            selectionRanges.append ([indexStart, indexEnd])
>          selectionRanges.sort(reverse=True)
>  
>          # now delete rows - since we reverse sorted, the
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Commits mailing list
> Commits at osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/commits
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/dev/attachments/20060215/502f404c/attachment.html


More information about the Dev mailing list