當前位置: 首頁>>代碼示例>>Python>>正文


Python Field.getIndexValue方法代碼示例

本文整理匯總了Python中appy.fields.Field.getIndexValue方法的典型用法代碼示例。如果您正苦於以下問題:Python Field.getIndexValue方法的具體用法?Python Field.getIndexValue怎麽用?Python Field.getIndexValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在appy.fields.Field的用法示例。


在下文中一共展示了Field.getIndexValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getIndexValue

# 需要導入模塊: from appy.fields import Field [as 別名]
# 或者: from appy.fields.Field import getIndexValue [as 別名]
 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
開發者ID:Sateanu,項目名稱:django-sis,代碼行數:19,代碼來源:string.py

示例2: getIndexValue

# 需要導入模塊: from appy.fields import Field [as 別名]
# 或者: from appy.fields.Field import getIndexValue [as 別名]
 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
開發者ID:dpineiden,項目名稱:gestion_docs,代碼行數:26,代碼來源:string.py


注:本文中的appy.fields.Field.getIndexValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。