当前位置: 首页>>代码示例>>Python>>正文


Python Field.isEmptyValue方法代码示例

本文整理汇总了Python中appy.fields.Field.isEmptyValue方法的典型用法代码示例。如果您正苦于以下问题:Python Field.isEmptyValue方法的具体用法?Python Field.isEmptyValue怎么用?Python Field.isEmptyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在appy.fields.Field的用法示例。


在下文中一共展示了Field.isEmptyValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: isEmptyValue

# 需要导入模块: from appy.fields import Field [as 别名]
# 或者: from appy.fields.Field import isEmptyValue [as 别名]
 def isEmptyValue(self, obj, value):
     '''Returns True if the p_value must be considered as an empty value.'''
     if not self.isMultilingual(obj):
         return Field.isEmptyValue(self, obj, value)
     # For a multilingual value, as soon as a value is not empty for a given
     # language, the whole value is considered as not being empty.
     if not value: return True
     for v in value.itervalues():
         if not Field.isEmptyValue(self, obj, v): return
     return True
开发者ID:dpineiden,项目名称:gestion_docs,代码行数:12,代码来源:string.py

示例2: getUnilingualFormattedValue

# 需要导入模块: from appy.fields import Field [as 别名]
# 或者: from appy.fields.Field import isEmptyValue [as 别名]
 def getUnilingualFormattedValue(self, obj, value, showChanges=False,
                                 userLanguage=None, language=None):
     '''If no p_language is specified, this method is called by
        m_getFormattedValue for getting a non-multilingual value (ie, in
        most cases). Else, this method returns a formatted value for the
        p_language-specific part of a multilingual value.'''
     if Field.isEmptyValue(self, obj, value): return ''
     res = value
     if self.isSelect:
         if isinstance(self.validator, Selection):
             # Value(s) come from a dynamic vocabulary
             val = self.validator
             if self.isMultiValued():
                 return [val.getText(obj, v, self, language=userLanguage) \
                         for v in value]
             else:
                 return val.getText(obj, value, self, language=userLanguage)
         else:
             # Value(s) come from a fixed vocabulary whose texts are in
             # i18n files.
             _ = obj.translate
             if self.isMultiValued():
                 res = [_('%s_list_%s' % (self.labelId, v), \
                          language=userLanguage) for v in value]
             else:
                 res = _('%s_list_%s' % (self.labelId, value), \
                         language=userLanguage)
     elif (self.format == String.XHTML) and showChanges:
         # Compute the successive changes that occurred on p_value.
         res = self.getDiffValue(obj, res, language)
     # If value starts with a carriage return, add a space; else, it will
     # be ignored.
     if isinstance(res, basestring) and \
        (res.startswith('\n') or res.startswith('\r\n')): res = ' ' + res
     return res
开发者ID:dpineiden,项目名称:gestion_docs,代码行数:37,代码来源:string.py

示例3: isCompleteValue

# 需要导入模块: from appy.fields import Field [as 别名]
# 或者: from appy.fields.Field import isEmptyValue [as 别名]
 def isCompleteValue(self, obj, value):
     '''Returns True if the p_value must be considered as complete. For a
        unilingual field, being complete simply means not being empty. For a
        multilingual field, being complete means that a value is present for
        every language.'''
     if not self.isMultilingual(obj):
         return Field.isCompleteValue(self, obj, value)
     # As soon as a given language value is empty, the global value is not
     # complete.
     if not value: return True
     for v in value.itervalues():
         if Field.isEmptyValue(self, obj, v): return
     return True
开发者ID:dpineiden,项目名称:gestion_docs,代码行数:15,代码来源:string.py

示例4: getUnilingualStorableValue

# 需要导入模块: from appy.fields import Field [as 别名]
# 或者: from appy.fields.Field import isEmptyValue [as 别名]
 def getUnilingualStorableValue(self, obj, value):
     isString = isinstance(value, basestring)
     isEmpty = Field.isEmptyValue(self, obj, value)
     # Apply transform if required
     if isString and not isEmpty and (self.transform != 'none'):
        value = self.applyTransform(value)
     # Clean XHTML strings
     if not isEmpty and (self.format == String.XHTML):
         # When image upload is allowed, ckeditor inserts some "style" attrs
         # (ie for image size when images are resized). So in this case we
         # can't remove style-related information.
         try:
             value = XhtmlCleaner(keepStyles=False).clean(value)
         except XhtmlCleaner.Error, e:
             # Errors while parsing p_value can't prevent the user from
             # storing it.
             pass
开发者ID:dpineiden,项目名称:gestion_docs,代码行数:19,代码来源:string.py

示例5: isEmptyValue

# 需要导入模块: from appy.fields import Field [as 别名]
# 或者: from appy.fields.Field import isEmptyValue [as 别名]
 def isEmptyValue(self, value, obj=None):
     '''Must p_value be considered as empty?'''
     if not obj: return Field.isEmptyValue(self, value)
     if value: return False
     # If "nochange", the value must not be considered as empty
     return obj.REQUEST.get('%s_delete' % self.name) != 'nochange'
开发者ID:Sateanu,项目名称:django-sis,代码行数:8,代码来源:file.py


注:本文中的appy.fields.Field.isEmptyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。