[Chandler-dev] When to use proxied items vs unproxied items?

Reid Ellis rae at osafoundation.org
Tue Mar 6 08:15:35 PST 2007


I am adding an item to the Test->Sharing menu, "Create Conflict", to  
better help with working on the conflict dialog. While doing this, I  
wrote this code in Blocks/PimBlocks.py:

     def onCreateConflictEvent(self, event):
         selectedItems = self.__getProxiedSelectedItems(event)
         if len(selectedItems) > 0:
             # only shared items can have conflicts
             for item in selectedItems:
                 if has_stamp(item, sharing.SharedItem):
     	            sharing.SharedItem(item).generateConflicts()

     def onCreateConflictEventUpdateUI(self, event):
         selectedItems = self.__getSelectedItems()
         if len(selectedItems) > 0:
             # Collect the states of all the items, so that we can  
change all
             # the items if they're all in the same state.
             states = [has_stamp(item, sharing.SharedItem) for item  
in selectedItems]
             # only enable for Notes and their subclasses (not  
collections, etc)
             enable = True in states
             event.arguments['Enable'] = enable

These are modelled on the numerous other event-handling methods in  
the FocusEventHandlers class. My (hopefully simple) question is: why  
do we use __getProxiedSelectedItems() for event handlers (which ends  
up calling Block.getProxiedItem()), but __getSelectedItems() (which  
does not call that function) for the UpdateUI methods? Shouldn't they  
both be using the proxy version?

Reid



More information about the chandler-dev mailing list