def index_html(self, REQUEST=None, RESPONSE=None): """Download the file """ field = self.getPrimaryField() if field.getContentType(self) in self.inlineMimetypes: # return the PDF and Office file formats inline return ATCTFileContent.index_html(self, REQUEST, RESPONSE) # otherwise return the content as an attachment # Please note that text/* cannot be returned inline as # this is a security risk (IE renders anything as HTML). return field.download(self)
def __bobo_traverse__(self, REQUEST, name): """Transparent access to image scales """ if name.startswith('image'): field = self.getField('image') image = None if name == 'image': image = field.getScale(self) else: scalename = name[len('image_'):] if scalename in field.getAvailableSizes(self): image = field.getScale(self, scale=scalename) if image is not None and not isinstance(image, basestring): # image might be None or '' for empty images return image return ATCTFileContent.__bobo_traverse__(self, REQUEST, name)
def index_html(self, REQUEST=None, RESPONSE=None): """ Download the file """ ## Mini-faq: ## Why this method override ATFile.index_html? ## As of ATCT 1.1.3-final: ATFile.index_html ## doesn't pass REQUEST nor RESPONSE to field.download method ## Where are the difference? ## Just compare the last line. field = self.getPrimaryField() if field.getContentType(self) in self.inlineMimetypes: # return the PDF and Office file formats inline return ATCTFileContent.index_html(self, REQUEST, RESPONSE) # otherwise return the content as an attachment # Please note that text/* cannot be returned inline as # this is a security risk (IE renders anything as HTML). ## Here, we pass REQUEST and RESPONSE to download(). return field.download(self, REQUEST, RESPONSE)
def __bobo_traverse__(self, REQUEST, name): """ Transparent access to referenced image scales """ if name.startswith('image'): ref_obj = self.getImage() if ref_obj: field = ref_obj.getField('image') image = None if name == 'image': image = field.getScale(ref_obj) else: scalename = name[len('image_'):] if scalename in field.getAvailableSizes(ref_obj): image = field.getScale(ref_obj, scale=scalename) if image is not None and not isinstance(image, basestring): # image might be None or '' for empty images return image else: return 'this image has been deleted!' return ATCTFileContent.__bobo_traverse__(self, REQUEST, name)