当前位置: 首页>>代码示例>>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;未经允许,请勿转载。