Esempio n. 1
0
  def save(self, *args, **kwargs):
    self.date = datetime.now()
    fspath = self.fspath

    if not self._ensure_base_dir_exists(fspath):
      raise NotFoundError("Base dir is not found for {}".format(fspath))

    if not os.path.exists(fspath):
      # We have to do this.. Should PROBABLY move this to new_project
      # TODO: move this to new project
      safe_mkdirs(self.base_dir)

      if self.is_directory:
        safe_mkdirs(fspath)
      else:
        # TODO: we need to worry about race conditions here as well.
        if self._content:
          self._content.save(fspath)

    return Document.save(self, *args, **kwargs)
Esempio n. 2
0
    def save(self, *args, **kwargs):
        self.date = datetime.now()
        fspath = self.fspath

        if not self._ensure_base_dir_exists(fspath):
            raise NotFoundError("Base dir is not found for {}".format(fspath))

        if not os.path.exists(fspath):
            # We have to do this.. Should PROBABLY move this to new_project
            # TODO: move this to new project
            safe_mkdirs(self.base_dir)

            if self.is_directory:
                safe_mkdirs(fspath)
            else:
                # TODO: we need to worry about race conditions here as well.
                if self._content:
                    self._content.save(fspath)

        return Document.save(self, *args, **kwargs)