Example #1
0
	def open_fileref(self, fileref):
		"""Open document specified by a FileRef."""
		doc = self.make_file_document(fileref)
		if not doc:
			raise ApplicationError("The file '%s' is not recognised by %s." % (
				fileref.name, Globals.application_name))
		doc.set_file(fileref)
		try:
			doc.read()
		except EnvironmentError, e:
			raise ApplicationError("Unable to open '%s'." % fileref.name, e)
Example #2
0
 def _save(self):
     for window in self.windows:
         window.broadcast('flush')
     if self._file == None:
         self.get_new_file_name()
     try:
         self.write()
     except EnvironmentError, e:
         raise ApplicationError("Unable to save '%s'." % self._file.name, e)
Example #3
0
 def save_cmd(self):
     """Implements the standard Save command. Writes the document to its
     associated file, asking the user for one first if necessary."""
     if self._file == None:
         self.get_new_file_name()
     try:
         self.write()
     except EnvironmentError, e:
         raise ApplicationError("Unable to save '%s'." % self._file.name, e)
Example #4
0
def raise_application_error():
    raise ApplicationError(
        "Your underpants are on fire.",
        "Please notify the fire service and proceed in an orderly manner to the nearest exit."
    )