iPhoto Generalized Logic (and appending photo name to comments)

I only started scripting iPhoto today, but I recall from a lot of work with other applications, the most of the scripts come down to the same basic logic. If you write it nice and generic, you can change only a few lines to make a new script. Here is my proposal for a basic iPhoto script structure. It seems to work. All you change is the “doTheThingToPhoto” handler and save the script to a new name.

(*adapted from a macscripter script
If an event is selected, the selection object will just be a list of photo ids
If multiple events are selected, the same is true
You cannot address items in the selection itself, but once you assign the selection to a variable, then you can!
It appears that you cannot have both albums and photos in the same selection
Faces, Places, Photos, Last Import, Flagged, and Trash are all albums. So are smart albums.
But beware, I clicked on 'Photos', since the last time I had browsed it, I had selected a photo, so it returned a photo as the selection.
tell application "iPhoto"
	set theSeln to selection
	if class of item 1 of theSeln is album then
		display dialog "Are you sure you want to do the thing to all the photos in the " & (count of theSeln) & " selected albums?" buttons {"Cancel", "OK"} default button 2
		-- if cancel is selected, Applescript will terminate the script automatically
		my processAlbums(theSeln)
		display dialog "Are you sure you want to do the thing to all " & (count of theSeln) & " selected photos?" buttons {"Cancel", "OK"} default button 2
		my processPix(theSeln)
	end if
end tell

on processAlbums(theSeln)
	repeat with oneAlbum in theSeln
		tell application "iPhoto"
			my processPix(photos of oneAlbum)
		end tell
	end repeat
end processAlbums

on processPix(theSeln)
	repeat with aPhoto in theSeln
		my doTheThingToPhoto(aPhoto)
	end repeat
end processPix

on doTheThingToPhoto(aPhoto)
	tell application "iPhoto"
		set theTitle to name of aPhoto
		if the comment of aPhoto is "" then
			set comment of aPhoto to theTitle
			set comment of aPhoto to comment of aPhoto & " - " & theTitle
		end if
	end tell
end doTheThingToPhoto