本文整理汇总了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
示例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
示例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
示例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
示例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'