def remove_atom(self, atom, **opts): # bruce 080311 added **opts to match superclass method signature """ Delete self if *any* of its atoms are deleted [overrides superclass method] """ Node.kill(self) # superclass is Jig, not Node; see long comment above
def kill(self, require_confirmation=True): """ Delete the POV-Ray Scene node and its associated .pov file if it exists. If <require_confirmation> is True, make the user confirm first [for deleting the file and the node both, as one op]. [WARNING: user confirmation is not yet implemented.] Otherwise, delete the file without user confirmation. """ if os.path.isfile(self.povrayscene_file): if 0: # Don't require confirmation for A8. Mark 060701. [but see comment below about why this is a bad bug] # if require_confirmation: msg = "Please confirm that you want to delete " + self.name from widgets.widget_helpers import PleaseConfirmMsgBox confirmed = PleaseConfirmMsgBox(msg) if not confirmed: return # warn the user that you are about to remove what might be an irreplaceable rendering of a prior version # of the main file, without asking, or even checking if other nodes in this assy still point to it # [this warning added by bruce 060711 for Mac A8, not present in Windows A8] env.history.message( orangemsg("Warning: deleting file [%s]" % self.povrayscene_file)) # do it os.remove(self.povrayscene_file) #bruce 060711 comment -- the above policy is a dangerous bug, since you can copy a node (not changing the filename) # and then delete one of the copies. This should not silently delete the file! # (Besides, even if you decide not to delete the file, .kill() should still delete the node.) # This behavior is so dangerous that I'm tempted to fix it for Mac A8 even though it's too late # to fix it for Windows A8. Certainly it ought to be reported and releasenoted. But I think I will refrain # from the temptation to fix it for Mac A8, since doing it well is not entirely trivial, and any big bug-difference # in A8 on different platforms might cause confusion. But at least I will add a history message, so the user knows # right away if it caused a problem. And it needs to be fixed decently well for A8.1. ###@@@ # As for a better behavior, it would be good (and not too hard) to find out if other nodes # in the same assy point to the same file, and not even ask (just don't delete the file) if they do. # If not, ask, but always delete the node itself. # But this is not trivial, since during a recursive kill of a Group, I'm not sure we can legally scan the tree. # (And if we did, it would then be quadratic time to delete a very large series of POV-Ray nodes.) # So we need a dictionary from filenames to lists or dicts of nodes that might refer to that filename. # Of course there should also (for any filenode) be CM commands to delete or rename the file, # or (if other nodes also point to it) to copy it so this node owns a unique one. Node.kill(self)
def kill(self, require_confirmation=True): """ Delete the POV-Ray Scene node and its associated .pov file if it exists. If <require_confirmation> is True, make the user confirm first [for deleting the file and the node both, as one op]. [WARNING: user confirmation is not yet implemented.] Otherwise, delete the file without user confirmation. """ if os.path.isfile(self.povrayscene_file): if 0: # Don't require confirmation for A8. Mark 060701. [but see comment below about why this is a bad bug] # if require_confirmation: msg = "Please confirm that you want to delete " + self.name from widgets.widget_helpers import PleaseConfirmMsgBox confirmed = PleaseConfirmMsgBox(msg) if not confirmed: return # warn the user that you are about to remove what might be an irreplaceable rendering of a prior version # of the main file, without asking, or even checking if other nodes in this assy still point to it # [this warning added by bruce 060711 for Mac A8, not present in Windows A8] env.history.message(orangemsg("Warning: deleting file [%s]" % self.povrayscene_file)) # do it os.remove(self.povrayscene_file) # bruce 060711 comment -- the above policy is a dangerous bug, since you can copy a node (not changing the filename) # and then delete one of the copies. This should not silently delete the file! # (Besides, even if you decide not to delete the file, .kill() should still delete the node.) # This behavior is so dangerous that I'm tempted to fix it for Mac A8 even though it's too late # to fix it for Windows A8. Certainly it ought to be reported and releasenoted. But I think I will refrain # from the temptation to fix it for Mac A8, since doing it well is not entirely trivial, and any big bug-difference # in A8 on different platforms might cause confusion. But at least I will add a history message, so the user knows # right away if it caused a problem. And it needs to be fixed decently well for A8.1. ###@@@ # As for a better behavior, it would be good (and not too hard) to find out if other nodes # in the same assy point to the same file, and not even ask (just don't delete the file) if they do. # If not, ask, but always delete the node itself. # But this is not trivial, since during a recursive kill of a Group, I'm not sure we can legally scan the tree. # (And if we did, it would then be quadratic time to delete a very large series of POV-Ray nodes.) # So we need a dictionary from filenames to lists or dicts of nodes that might refer to that filename. # Of course there should also (for any filenode) be CM commands to delete or rename the file, # or (if other nodes also point to it) to copy it so this node owns a unique one. Node.kill(self)