I needed to pass a path to DICOM file to a certain CLI module because that module needed metadata from the header. But to get the path depends on how the node was loaded, via drag-drop or via DICOM browser. Here is a function which works for both cases:
def PathFromNode(self, node):
storageNode=node.GetStorageNode()
if storageNode is not None:
filepath=storageNode.GetFullNameFromFileName()
else:
instanceUIDs=node.GetAttribute('DICOM.instanceUIDs').split()
filepath=slicer.dicomDatabase.fileForInstance(instUids[0])
return filepath
# example invocation
node=slicer.util.getFirstNodeByName('volume1')
path=self.PathFromNode(node)
print "DICOM path="+path