def handleBlobAttrs(self, name, REQUEST): langs = self.getLangIds() name_without_lang_suffix = name if len(langs) == 1 and name.find('_%s.' % langs[0]) > 0: name_without_lang_suffix = name.replace('_%s.' % langs[0], '.') for ob in [self] + self.filteredChildNodes(REQUEST, ['ZMSFile']): for key in ob.getObjAttrs(): obj_attr = ob.getObjAttr(key) datatype = obj_attr['datatype_key'] if datatype in _globals.DT_BLOBS: lang = ob.getLanguageFromName(REQUEST['URL']) REQUEST.set('lang', lang) value = ob.getObjProperty(key, REQUEST) if value is not None: href = value.getHref(REQUEST) langfilename = href.split('/')[-1] if langfilename.find('?') > 0: langfilename = langfilename[:langfilename.find('?')] if langfilename == name or \ langfilename == standard.url_encode(name) or \ langfilename == name_without_lang_suffix or \ langfilename == standard.url_encode(name_without_lang_suffix): return value return None
def getHref(self, REQUEST): """ Returns absolute url. @var REQUEST: the triggering request @type REQUEST: ZPublisher.HTTPRequest """ parent = self.aq_parent key = self.key rownum = '' i = key.find( ':') if i > 0: rownum = '/@%s'%key[ i+1:] filename = getLangFilename( parent, self.getFilename(), self.lang) filename = standard.url_encode( filename) qs = '' zms_version_key = 'ZMS_VERSION_%s'%parent.id if REQUEST.get( zms_version_key, None) is not None: qs = standard.qs_append( qs, zms_version_key, REQUEST.get( zms_version_key)) elif standard.isPreviewRequest( REQUEST): qs = standard.qs_append( qs, 'preview', 'preview') base = '/'.join(parent.getPhysicalPath()) href = base+rownum+'/'+filename+qs return href