Logo Search packages:      
Sourcecode: zope-extfile version File versions

def zope-extfile-1.4.2::ExtImage::ExtImage::manage_file_upload (   self,
  file = '',
  content_type = '',
  is_preview = 0,
  create_prev = NO_PREVIEW,
  maxx = '',
  maxy = '',
  ratio = 0,
  REQUEST = None 
)

Upload image from file handle or local directory 

Definition at line 333 of file ExtImage.py.

                                        :
        """ Upload image from file handle or local directory """
        if self.wl_isLocked():
            raise ResourceLockedError, "File is locked via WebDAV"

        if is_preview:
            if type(file) == types.StringType:
                cant_read_exc = "Can't open: "
                try: file = open(file, 'rb')
                except: raise cant_read_exc, file
            maxx, maxy = self._formatDimensions(maxx, maxy)
            if create_prev==UPLOAD_RESIZE and maxx!=0 and maxy!=0:
                self._register()    # Register with TM
                try:
                    new_fn = self._get_ufn(self.prev_filename, content_type='image/jpeg')
                    self._update_data(file, self._temp_fsname(new_fn))
                finally: self._dir__unlock()
                self._createPreview(new_fn, new_fn, maxx, maxy, ratio)
            else:
                if content_type:
                    file = HTTPUpload(file, content_type)
                self.prev_content_type = self._get_content_type(file, file.read(100), 
                                         self.id, self.prev_content_type)
                file.seek(0)
                self._register()    # Register with TM
                try:
                    new_fn = self._get_ufn(self.prev_filename, content_type=self.prev_content_type)
                    self._update_data(file, self._temp_fsname(new_fn))
                finally: self._dir__unlock()
                self.prev_filename = new_fn
                self._initPreview()
        else:
            ExtImage.inheritedAttribute("manage_file_upload")(self, file, content_type)
            if create_prev==GENERATE:
                maxx, maxy = self._formatDimensions(maxx, maxy)
                if maxx!=0 and maxy!=0:
                    self._register()    # Register with TM
                    try:
                        new_fn = self._get_ufn(self.prev_filename, content_type='image/jpeg')
                        self._createPreview(self.filename, new_fn, maxx, maxy, ratio)
                    finally: self._dir__unlock()
        if REQUEST is not None:
            return self.manage_main(self, REQUEST, manage_tabs_message='Upload complete.')
    
    security.declareProtected(ChangePermission, 'manage_http_upload')
    def manage_http_upload(self, url, is_preview=0, REQUEST=None):


Generated by  Doxygen 1.6.0   Back to index