Title: [commits] (john) [8960] ModifyCollection event handler now
calls an onInit method on the item that's being added to a collection,
if it exists.
John -
onInit seems like a very generic method name for such a specific type
of event. Further I can imagine using ModifyCollection to add items to
other collections as well, so this method might be called multiple
times for different target collections.
Perhaps we could call this onAddToCollection() and also pass in the
collection that the item was added to?
Alec
[email protected] wrote:
- Revision
- 8960
- Author
- john
- Date
- 2006-01-09 11:10:33 -0800 (Mon, 09 Jan 2006)
Log Message
ModifyCollection event handler now calls an
onInit method on the item that's being added to a collection, if it
exists. This allows parcels, like flickr to move the dialog code into
onInit, eliminating a custom event and the controller.
Modified Paths
Diff
Modified: trunk/chandler/parcels/osaf/framework/blocks/Block.py
(8959 => 8960)
--- trunk/chandler/parcels/osaf/framework/blocks/Block.py 2006-01-09 18:31:06 UTC (rev 8959)
+++ trunk/chandler/parcels/osaf/framework/blocks/Block.py 2006-01-09 19:10:33 UTC (rev 8960)
@@ -502,7 +502,17 @@
else:
item.displayName = newDisplayName
break
-
+
+ # Call the item's onInit method if it has one. If it returns None
+ # Exit. If it returns something else, add that to the collection
+ # instead of the item.
+ method = getattr (type (item), "onInit", None)
+ if method:
+ result = method (widget)
+ if result is False:
+ return
+ if result is not None:
+ item = result
collection.add (item)
# Optionally select the item in a named block and p;ossibly edit
_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev