Пример #1
0
 def getIndexValue(self, obj, forSearch=False):
     '''For indexing purposes, we return only strings, not unicodes.'''
     res = Field.getIndexValue(self, obj, forSearch)
     if isinstance(res, unicode):
         res = res.encode('utf-8')
     if res and forSearch and (self.format == String.XHTML):
         # Convert the value to simple text.
         extractor = XhtmlTextExtractor(raiseOnError=False)
         res = extractor.parse('<p>%s</p>' % res)
     # Ugly catalog: if I give an empty tuple as index value, it keeps the
     # previous value. If I give him a tuple containing an empty string, it
     # is ok.
     if isinstance(res, tuple) and not res: res = self.emptyStringTuple
     # Ugly catalog: if value is an empty string or None, it keeps the
     # previous index value.
     if res in self.emptyValuesCatalogIgnored: res = ' '
     return res
Пример #2
0
 def getIndexValue(self, obj, forSearch=False):
     '''For indexing purposes, we return only strings, not unicodes.'''
     res = Field.getIndexValue(self, obj, forSearch)
     if isinstance(res, unicode):
         res = res.encode('utf-8')
     if res and forSearch and (self.format == String.XHTML):
         # Convert the value to simple text.
         extractor = XhtmlTextExtractor(raiseOnError=False)
         res = extractor.parse('<p>%s</p>' % res)
     # Ugly catalog: if I give an empty tuple as index value, it keeps the
     # previous value. If I give him a tuple containing an empty string, it
     # is ok.
     if isinstance(res, tuple) and not res: res = self.emptyStringTuple
     # Ugly catalog: if value is an empty string or None, it keeps the
     # previous index value.
     if res in self.emptyValuesCatalogIgnored: res = ' '
     return res
Пример #3
0
 def getIndexValue(self, obj, forSearch=False):
     '''Pure text must be extracted from rich content; multilingual content
        must be concatenated.'''
     isXhtml = self.format == String.XHTML
     if self.isMultilingual(obj):
         res = self.getValue(obj)
         if res:
             vals = []
             for v in res.itervalues():
                 if isinstance(v, unicode): v = v.encode('utf-8')
                 if isXhtml: vals.append(self.extractText(v))
                 else: vals.append(v)
             res = ' '.join(vals)
     else:
         res = Field.getIndexValue(self, obj, forSearch)
         if res and isXhtml: res = self.extractText(res)
     # Ugly catalog: if I give an empty tuple as index value, it keeps the
     # previous value. If I give him a tuple containing an empty string, it
     # is ok.
     if isinstance(res, tuple) and not res: res = self.emptyStringTuple
     # Ugly catalog: if value is an empty string or None, it keeps the
     # previous index value.
     if res in self.emptyValuesCatalogIgnored: res = ' '
     return res
Пример #4
0
 def getIndexValue(self, obj, forSearch=False):
     '''Pure text must be extracted from rich content; multilingual content
        must be concatenated.'''
     isXhtml = self.format == String.XHTML
     if self.isMultilingual(obj):
         res = self.getValue(obj)
         if res:
             vals = []
             for v in res.itervalues():
                 if isinstance(v, unicode): v = v.encode('utf-8')
                 if isXhtml: vals.append(self.extractText(v))
                 else: vals.append(v)
             res = ' '.join(vals)
     else:
         res = Field.getIndexValue(self, obj, forSearch)
         if res and isXhtml: res = self.extractText(res)
     # Ugly catalog: if I give an empty tuple as index value, it keeps the
     # previous value. If I give him a tuple containing an empty string, it
     # is ok.
     if isinstance(res, tuple) and not res: res = self.emptyStringTuple
     # Ugly catalog: if value is an empty string or None, it keeps the
     # previous index value.
     if res in self.emptyValuesCatalogIgnored: res = ' '
     return res