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

def zope-extfile-1.4.2::ExtImage::ExtImage::manage_http_upload (   self,
  url,
  is_preview = 0,
  REQUEST = None 
)

Upload image from http-server 

Definition at line 380 of file ExtImage.py.

00380                                                                  :
        """ Upload image from http-server """
        if self.wl_isLocked():
            raise ResourceLockedError, "File is locked via WebDAV"

        if is_preview:
            url = urllib.quote(url,'/:')
            cant_read_exc = "Can't open: "
            try: file = urllib.urlopen(url)
            except: raise cant_read_exc, url
            file = HTTPUpload(file)
            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_http_upload")(self, url)
            if self.has_preview:
                width, height = self._getImageSize(self.prev_filename)
                self._register()    # Register with TM
                try:
                    new_fn = self._get_ufn(self.prev_filename, content_type='image/jpeg')
                    self._createPreview(self.filename, new_fn, width, height, self.prev_ratio)
                finally: self._dir__unlock()
        if REQUEST is not None:
            return self.manage_main(self, REQUEST, manage_tabs_message='Upload complete.')
    
    security.declareProtected(ChangePermission, 'PUT')
    def PUT(self, REQUEST, RESPONSE):


Generated by  Doxygen 1.6.0   Back to index