[gen] Bugfixes.

This commit is contained in:
Gaetan Delannay 2015-02-23 12:38:49 +01:00
parent af635f936f
commit dd7e2000a1
4 changed files with 17 additions and 15 deletions

View file

@ -30,7 +30,7 @@ class Field:
'''Basic abstract class for defining any field.'''
# Some global static variables
nullValues = (None, '', [])
nullValues = (None, '', [], {})
validatorTypes = (types.FunctionType, types.UnboundMethodType,
type(re.compile('')))
labelTypes = ('label', 'descr', 'help')

View file

@ -557,15 +557,14 @@ class String(Field):
return res
def isEmptyValue(self, obj, value):
'''Returns True if the p_value must be considered as an empty value.'''
if not self.isMultilingual(obj):
'''Returns True if the p_value must be considered as an empty value'''
if not isinstance(obj, dict):
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
# p_value is a dict of multilingual values. For such values, as soon
# as a value is not empty for a given language, the whole value is
# considered as not being empty.
for v in value.itervalues():
if not Field.isEmptyValue(self, obj, v): return
return True
def isCompleteValue(self, obj, value):
'''Returns True if the p_value must be considered as complete. For a
@ -910,12 +909,15 @@ class String(Field):
if rq.get('cancel') == 'True': return
requestValue = rq['fieldContent']
# Remember previous value if the field is historized
previousData = obj.rememberPreviousData([self])
isHistorized = self.getAttribute(obj, 'historized')
previousData = None
if isHistorized: previousData = obj.rememberPreviousData([self])
if self.isMultilingual(obj):
# We take a copy of previousData because it is mutable (dict)
prevData = previousData[self.name]
if prevData != None: prevData = prevData.copy()
previousData[self.name] = prevData
if isHistorized:
# We take a copy of previousData because it is mutable (dict)
prevData = previousData[self.name]
if prevData != None: prevData = prevData.copy()
previousData[self.name] = prevData
# We get a partial value, for one language only
language = rq['languageOnly']
v = self.getUnilingualStorableValue(obj, requestValue)
@ -925,7 +927,7 @@ class String(Field):
self.store(obj, self.getStorableValue(obj, requestValue))
part = ''
# Update the object history when relevant
if previousData: obj.historizeData(previousData)
if isHistorized and previousData: obj.historizeData(previousData)
# Update obj's last modification date
from DateTime import DateTime
obj.modified = DateTime()

View file

@ -1189,7 +1189,7 @@ class BaseMixin:
if not includeInvisible:
history = [e for e in history if e['comments'] != '_invisible_']
if reverse: history.reverse()
# Keep only events which are within the batch.
# Keep only events which are within the batch
res = []
stopIndex = startNumber + batchSize - 1
i = -1

View file

@ -31,7 +31,7 @@ class Merger:
self.i = 0
# The delta index that must be applied on previous diffs
self.deltaPrevious = 0
# A link to the caller HtmlDiff class.
# A link to the caller HtmlDiff class
self.differ = differ
def computeNewDiffs(self):