Bugfix in the system for refreshing layouts, and removed generation of '_valid' i18n labels, that almost doubled the size of po files and are almost never needed.

This commit is contained in:
Gaetan Delannay 2010-11-16 15:32:47 +01:00
parent 3fd2d62b30
commit cccdc12372
6 changed files with 15 additions and 16 deletions

View file

@ -132,7 +132,6 @@ class FieldDescriptor:
# Add the POD-related fields on the Tool
self.generator.tool.addPodRelatedFields(self)
notToValidateFields = ('Info', 'Computed', 'Action', 'Pod')
def walkAppyType(self):
'''Walks into the Appy type definition and gathers data about the
i18n labels.'''
@ -149,13 +148,6 @@ class FieldDescriptor:
self.classDescr.addIndexMethod(self)
# - searchable ? TODO
#if self.appyType.searchable: self.fieldParams['searchable'] = True
# - need to generate a field validator?
# In all cases excepted for "immutable" fields, add an i18n message for
# the validation error for this field.
if self.appyType.type not in self.notToValidateFields:
label = '%s_%s_valid' % (self.classDescr.name, self.fieldName)
poMsg = PoMessage(label, '', PoMessage.DEFAULT_VALID_ERROR)
self.generator.labels.append(poMsg)
# i18n labels
i18nPrefix = "%s_%s" % (self.classDescr.name, self.fieldName)
# Create labels for generating them in i18n files.

View file

@ -141,6 +141,7 @@ class Generator(AbstractGenerator):
msg('yes', '', msg.YES),
msg('no', '', msg.NO),
msg('field_required', '', msg.FIELD_REQUIRED),
msg('field_invalid', '', msg.FIELD_INVALID),
msg('file_required', '', msg.FILE_REQUIRED),
msg('image_required', '', msg.IMAGE_REQUIRED),
]

View file

@ -142,9 +142,7 @@ class BaseMixin:
for key, value in errors.__dict__.iteritems():
resValue = value
if not isinstance(resValue, basestring):
appyType = self.getAppyType(key)
msgId = '%s_valid' % appyType.labelId
resValue = self.translate(msgId)
resValue = self.translate('field_invalid')
setattr(errors, key, resValue)
def onUpdate(self):
@ -395,6 +393,14 @@ class BaseMixin:
exec 'import %s' % moduleName
exec 'reload(%s)' % moduleName
exec 'res = %s.%s' % (moduleName, klass.__name__)
# More manipulations may have occurred in m_update
if hasattr(res, 'update'):
parentName = res.__bases__[-1].__name__
moduleName = 'Products.%s.Extensions.appyWrappers' % \
self.getTool().getAppName()
exec 'import %s' % moduleName
exec 'parent = %s.%s' % (moduleName, parentName)
res.update(parent)
return res
def getAppyType(self, name, asDict=False, className=None):