diff --git a/doc/version.txt b/doc/version.txt index a918a2a..ee6cdce 100644 --- a/doc/version.txt +++ b/doc/version.txt @@ -1 +1 @@ -0.6.0 +0.6.1 diff --git a/gen/__init__.py b/gen/__init__.py index 57ee232..c2723cd 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -749,11 +749,11 @@ class Type: return validValue else: if not validValue: - return obj.translate('%s_valid' % self.labelId) + return obj.translate('field_invalid') except Exception, e: return str(e) except: - return obj.translate('%s_valid' % self.labelId) + return obj.translate('field_invalid') else: # It is a regular expression if not self.validator.match(value): @@ -766,7 +766,7 @@ class Type: elif self.validator == String.ALPHANUMERIC: return obj.translate('bad_alphanumeric') else: - return obj.translate('%s_valid' % self.labelId) + return obj.translate('field_invalid') def store(self, obj, value): '''Stores the p_value (produced by m_getStorableValue) that complies to diff --git a/gen/plone25/descriptors.py b/gen/plone25/descriptors.py index 4ed4794..69f5a01 100644 --- a/gen/plone25/descriptors.py +++ b/gen/plone25/descriptors.py @@ -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. diff --git a/gen/plone25/generator.py b/gen/plone25/generator.py index b965df2..7311c70 100644 --- a/gen/plone25/generator.py +++ b/gen/plone25/generator.py @@ -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), ] diff --git a/gen/plone25/mixins/__init__.py b/gen/plone25/mixins/__init__.py index 1cd7c7d..0291387 100644 --- a/gen/plone25/mixins/__init__.py +++ b/gen/plone25/mixins/__init__.py @@ -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): diff --git a/gen/po.py b/gen/po.py index 9be7602..11b8fe8 100644 --- a/gen/po.py +++ b/gen/po.py @@ -44,7 +44,6 @@ class PoMessage: MSG_showAllStatesInPhase = 'Show all states in phase' USER = 'User' POD_ASKACTION = 'Trigger related action' - DEFAULT_VALID_ERROR = 'Please fill or correct this.' REF_NO = 'No object.' REF_ADD = 'Add a new one' REF_NAME = 'Name' @@ -110,6 +109,7 @@ class PoMessage: NO = 'No' FIELD_REQUIRED = 'Please fill this field.' FILE_REQUIRED = 'Please select a file.' + FIELD_INVALID = 'Please fill or correct this.' IMAGE_REQUIRED = 'The uploaded file must be an image.' def __init__(self, id, msg, default, fuzzy=False, comments=[],