[gen] Bugfixes.
This commit is contained in:
parent
af635f936f
commit
dd7e2000a1
|
@ -30,7 +30,7 @@ class Field:
|
||||||
'''Basic abstract class for defining any field.'''
|
'''Basic abstract class for defining any field.'''
|
||||||
|
|
||||||
# Some global static variables
|
# Some global static variables
|
||||||
nullValues = (None, '', [])
|
nullValues = (None, '', [], {})
|
||||||
validatorTypes = (types.FunctionType, types.UnboundMethodType,
|
validatorTypes = (types.FunctionType, types.UnboundMethodType,
|
||||||
type(re.compile('')))
|
type(re.compile('')))
|
||||||
labelTypes = ('label', 'descr', 'help')
|
labelTypes = ('label', 'descr', 'help')
|
||||||
|
|
|
@ -557,15 +557,14 @@ class String(Field):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def isEmptyValue(self, obj, value):
|
def isEmptyValue(self, obj, value):
|
||||||
'''Returns True if the p_value must be considered as an empty value.'''
|
'''Returns True if the p_value must be considered as an empty value'''
|
||||||
if not self.isMultilingual(obj):
|
if not isinstance(obj, dict):
|
||||||
return Field.isEmptyValue(self, obj, value)
|
return Field.isEmptyValue(self, obj, value)
|
||||||
# For a multilingual value, as soon as a value is not empty for a given
|
# p_value is a dict of multilingual values. For such values, as soon
|
||||||
# language, the whole value is considered as not being empty.
|
# as a value is not empty for a given language, the whole value is
|
||||||
if not value: return True
|
# considered as not being empty.
|
||||||
for v in value.itervalues():
|
for v in value.itervalues():
|
||||||
if not Field.isEmptyValue(self, obj, v): return
|
if not Field.isEmptyValue(self, obj, v): return
|
||||||
return True
|
|
||||||
|
|
||||||
def isCompleteValue(self, obj, value):
|
def isCompleteValue(self, obj, value):
|
||||||
'''Returns True if the p_value must be considered as complete. For a
|
'''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
|
if rq.get('cancel') == 'True': return
|
||||||
requestValue = rq['fieldContent']
|
requestValue = rq['fieldContent']
|
||||||
# Remember previous value if the field is historized
|
# 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):
|
if self.isMultilingual(obj):
|
||||||
# We take a copy of previousData because it is mutable (dict)
|
if isHistorized:
|
||||||
prevData = previousData[self.name]
|
# We take a copy of previousData because it is mutable (dict)
|
||||||
if prevData != None: prevData = prevData.copy()
|
prevData = previousData[self.name]
|
||||||
previousData[self.name] = prevData
|
if prevData != None: prevData = prevData.copy()
|
||||||
|
previousData[self.name] = prevData
|
||||||
# We get a partial value, for one language only
|
# We get a partial value, for one language only
|
||||||
language = rq['languageOnly']
|
language = rq['languageOnly']
|
||||||
v = self.getUnilingualStorableValue(obj, requestValue)
|
v = self.getUnilingualStorableValue(obj, requestValue)
|
||||||
|
@ -925,7 +927,7 @@ class String(Field):
|
||||||
self.store(obj, self.getStorableValue(obj, requestValue))
|
self.store(obj, self.getStorableValue(obj, requestValue))
|
||||||
part = ''
|
part = ''
|
||||||
# Update the object history when relevant
|
# Update the object history when relevant
|
||||||
if previousData: obj.historizeData(previousData)
|
if isHistorized and previousData: obj.historizeData(previousData)
|
||||||
# Update obj's last modification date
|
# Update obj's last modification date
|
||||||
from DateTime import DateTime
|
from DateTime import DateTime
|
||||||
obj.modified = DateTime()
|
obj.modified = DateTime()
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ class BaseMixin:
|
||||||
if not includeInvisible:
|
if not includeInvisible:
|
||||||
history = [e for e in history if e['comments'] != '_invisible_']
|
history = [e for e in history if e['comments'] != '_invisible_']
|
||||||
if reverse: history.reverse()
|
if reverse: history.reverse()
|
||||||
# Keep only events which are within the batch.
|
# Keep only events which are within the batch
|
||||||
res = []
|
res = []
|
||||||
stopIndex = startNumber + batchSize - 1
|
stopIndex = startNumber + batchSize - 1
|
||||||
i = -1
|
i = -1
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Merger:
|
||||||
self.i = 0
|
self.i = 0
|
||||||
# The delta index that must be applied on previous diffs
|
# The delta index that must be applied on previous diffs
|
||||||
self.deltaPrevious = 0
|
self.deltaPrevious = 0
|
||||||
# A link to the caller HtmlDiff class.
|
# A link to the caller HtmlDiff class
|
||||||
self.differ = differ
|
self.differ = differ
|
||||||
|
|
||||||
def computeNewDiffs(self):
|
def computeNewDiffs(self):
|
||||||
|
|
Loading…
Reference in a new issue