def view(self, wait=True, tempname="/tmp/seltable"):
        import os
        viewed = False
        type = self.info()["type"]
        if type == "Measurement Set" or type == "Image":
            if os.system('test -x `which casaviewer` > /dev/null 2>&1') == 0:
                waitstr1 = ""
                waitstr2 = "foreground ..."
                if not wait:
                    waitstr1 = " &"
                    waitstr2 = "background ..."
                if self.iswritable():
                    six.print_("Flushing data and starting casaviewer " +
                               "in the " + waitstr2)
                else:
                    six.print_("Starting casaviewer in the " + waitstr2)
                self.flush()
                self.unlock()
                if os.system('test -e ' + self.name() + '/table.dat') == 0:
                    os.system('casaviewer ' + self.name() + waitstr1)
                    viewed = True
                elif len(tempname) > 0:
                    six.print_("  making a persistent copy in table " +
                               tempname)
                    self.copy(tempname)
                    os.system('casaviewer ' + tempname + waitstr1)
                    viewed = True
                    if wait:
                        from casacore.tables import tabledelete
                        six.print_("  finished viewing")
                        tabledelete(tempname)
                    else:
                        six.print_("  after viewing use tabledelete('" +
                                   tempname + "') to delete the copy")
                else:
                    six.print_("Cannot browse because the table is " +
                               "in memory only.")
                    six.print_("You can browse a (shallow) persistent " +
                               "copy of the table like:")
                    six.print_("   t.view(True, '/tmp/tab1')")
        if not viewed:
            self.browse(wait, tempname)