diff --git a/product/ERP5/Document/AccountingTransactionBalanceConstraint.py b/product/ERP5/Document/AccountingTransactionBalanceConstraint.py index 6629f41610d6bf7d60d3d946d84873a18778b63a..66135ba4d3652f562899335d18fd37b2f4edd228 100644 --- a/product/ERP5/Document/AccountingTransactionBalanceConstraint.py +++ b/product/ERP5/Document/AccountingTransactionBalanceConstraint.py @@ -41,8 +41,6 @@ class AccountingTransactionBalanceConstraint(ConstraintMixin): meta_type = 'ERP5 Accounting Transaction Balance Constraint' portal_type = 'Accounting Transaction Balance Constraint' - __compatibility_class_name__ = 'AccountingTransactionBalance' - property_sheets = ConstraintMixin.property_sheets + \ (PropertySheet.AccountingTransactionBalanceConstraint,) diff --git a/product/ERP5/Document/ResourceMeasuresConsistencyConstraint.py b/product/ERP5/Document/ResourceMeasuresConsistencyConstraint.py index 0dc836e52d8d92004f9b03e06654417f6d4c7a5e..bae2426e97117e5164026d8fba2a1dbc1bee53b8 100644 --- a/product/ERP5/Document/ResourceMeasuresConsistencyConstraint.py +++ b/product/ERP5/Document/ResourceMeasuresConsistencyConstraint.py @@ -43,8 +43,6 @@ class ResourceMeasuresConsistencyConstraint(ConstraintMixin): meta_type = 'ERP5 Resource Measures Consistency Constraint' portal_type = 'Resource Measures Consistency Constraint' - __compatibility_class_name__ = 'ResourceMeasuresConsistency' - property_sheets = ConstraintMixin.property_sheets + \ (PropertySheet.ResourceMeasuresConsistencyConstraint,) diff --git a/product/ERP5/Document/TradeModelLineCellConsistencyConstraint.py b/product/ERP5/Document/TradeModelLineCellConsistencyConstraint.py index 6a95bcd21e263edfcc2a2deda9c1e34284f01e1a..2e9bd3aebd7d20edbe0e70898104cefcccb1c238 100644 --- a/product/ERP5/Document/TradeModelLineCellConsistencyConstraint.py +++ b/product/ERP5/Document/TradeModelLineCellConsistencyConstraint.py @@ -42,8 +42,6 @@ class TradeModelLineCellConsistencyConstraint(ConstraintMixin): meta_type = 'ERP5 Trade Model Line Cell Consistency Constraint' portal_type = 'Trade Model Line Cell Consistency Constraint' - __compatibility_class_name__ = 'TradeModelLineCellConsistency' - property_sheets = ConstraintMixin.property_sheets + \ (PropertySheet.TradeModelLineCellConsistencyConstraint,) @@ -68,11 +66,3 @@ class TradeModelLineCellConsistencyConstraint(ConstraintMixin): @see ERP5Type.mixin.constraint.ConstraintMixin._convertFromFilesystemDefinition """ yield dict(base_id=base_id) - - def exportToFilesystemDefinitionDict(self): - filesystem_definition_dict = super(TradeModelLineCellConsistencyConstraint, - self).exportToFilesystemDefinitionDict() - - filesystem_definition_dict['base_id'] = self.getBaseId() - - return filesystem_definition_dict diff --git a/product/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py b/product/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py index 40bbfc6deb7dffa42727ff65d6b83a4bd0efbe44..d3b6fb8e8b2ef6e060fd7b1823e75d133f579995 100644 --- a/product/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py +++ b/product/ERP5/Document/TransactionQuantityValueFeasabilityConstraint.py @@ -41,8 +41,6 @@ class TransactionQuantityValueFeasabilityConstraint(ConstraintMixin): meta_type = 'ERP5 Transaction Quantity Value Feasability Constraint' portal_type = 'Transaction Quantity Value Feasability Constraint' - __compatibility_class_name__ = 'TransactionQuantityValueFeasability' - def _checkConsistency(self, object, fixit=0): """ Check if the quantity of the transaction is possible diff --git a/product/ERP5/Document/TransactionQuantityValueValidityConstraint.py b/product/ERP5/Document/TransactionQuantityValueValidityConstraint.py index 2b505a6b3187e1294bcdc37ccfa48c5da863fbb6..6d04e76b558312b24047d93fc3fda972edc0d7d4 100644 --- a/product/ERP5/Document/TransactionQuantityValueValidityConstraint.py +++ b/product/ERP5/Document/TransactionQuantityValueValidityConstraint.py @@ -38,8 +38,6 @@ class TransactionQuantityValueValidityConstraint(ConstraintMixin): meta_type = 'ERP5 Transaction Quantity Value Validity Constraint' portal_type = 'Transaction Quantity Value Validity Constraint' - __compatibility_class_name__ = 'TransactionQuantityValueValidity' - def _checkConsistency(self, object, fixit=0): """ Check if the quantity of the transaction is greater than the diff --git a/product/ERP5Type/Core/AcquiredProperty.py b/product/ERP5Type/Core/AcquiredProperty.py index a399b43fca042cf632eb56da1a9c9fd2c6059444..ca165e6d5bd7af66cbd06c0cb3e62a026a982f24 100644 --- a/product/ERP5Type/Core/AcquiredProperty.py +++ b/product/ERP5Type/Core/AcquiredProperty.py @@ -140,42 +140,6 @@ class AcquiredProperty(StandardProperty): 'content_translation_acquired_property_id', 'lines') - # TODO: remove - security.declareProtected(Permissions.AccessContentsInformation, - 'exportToFilesystemDefinition') - def exportToFilesystemDefinition(self): - """ - Return the filesystem definition of this ZODB property - - NOTE: Only meaningful for testing export of filesystem Property - Sheet to the ZODB - """ - filesystem_property_dict = \ - StandardProperty.exportToFilesystemDefinition(self) - - if filesystem_property_dict is None: - return None - - acquisition_portal_type_expression = self._getExpressionFromString( - self.getAcquisitionPortalType()) - - portal_type_expression = self._getExpressionFromString( - self.getContentPortalType()) - - filesystem_property_dict.update({ - 'acquisition_base_category': self.getAcquisitionBaseCategoryList(), - 'acquisition_object_id': self.getAcquisitionObjectIdList(), - 'acquisition_portal_type': acquisition_portal_type_expression, - 'acquisition_accessor_id': self.getAcquisitionAccessorId(), - 'alt_accessor_id': self.getAltAccessorIdList(), - 'acquisition_copy_value': self.getAcquisitionCopyValue(), - 'acquisition_mask_value': self.getAcquisitionMaskValue(), - 'portal_type': portal_type_expression, - 'acquired_property_id': self.getContentAcquiredPropertyIdList(), - 'translation_acquired_property_id': self.getContentTranslationAcquiredPropertyIdList()}) - - return filesystem_property_dict - @classmethod def _asPropertyMap(cls, property_dict): """ diff --git a/product/ERP5Type/Core/AttributeEqualityConstraint.py b/product/ERP5Type/Core/AttributeEqualityConstraint.py index 74a521cdb55d9acf9c30bebaf2b5ac119c1c83f8..ad5fb132482ea115363490489a0be850450c8350 100644 --- a/product/ERP5Type/Core/AttributeEqualityConstraint.py +++ b/product/ERP5Type/Core/AttributeEqualityConstraint.py @@ -59,8 +59,6 @@ class AttributeEqualityConstraint(PropertyExistenceConstraint): meta_type = 'ERP5 Attribute Equality Constraint' portal_type = 'Attribute Equality Constraint' - __compatibility_class_name__ = 'AttributeEquality' - # Declarative security security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) @@ -136,12 +134,3 @@ class AttributeEqualityConstraint(PropertyExistenceConstraint): """ for name, value in property_dict.iteritems(): yield dict(name=value) - - def exportToFilesystemDefinitionDict(self): - filesystem_definition_dict = super(AttributeEqualityConstraint, - self).exportToFilesystemDefinitionDict() - - filesystem_definition_dict[self.getConstraintAttributeName()] = \ - Expression(self.getConstraintAttributeValue()) - - return filesystem_definition_dict diff --git a/product/ERP5Type/Core/CategoryExistenceConstraint.py b/product/ERP5Type/Core/CategoryExistenceConstraint.py index 9a4e0b427aba4b616f0c88a8a7694b67516e4374..2cafdc71176c311b7a171b672f919ae902770a27 100644 --- a/product/ERP5Type/Core/CategoryExistenceConstraint.py +++ b/product/ERP5Type/Core/CategoryExistenceConstraint.py @@ -46,8 +46,6 @@ class CategoryExistenceConstraint(ConstraintMixin): meta_type = 'ERP5 Category Existence Constraint' portal_type = 'Category Existence Constraint' - __compatibility_class_name__ = 'CategoryExistence' - # Declarative security security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) @@ -125,21 +123,3 @@ class CategoryExistenceConstraint(ConstraintMixin): yield dict(constraint_base_category_list=base_category_dict.keys(), constraint_portal_type=constraint_portal_type_str) - - def exportToFilesystemDefinitionDict(self): - filesystem_definition_dict = super(CategoryExistenceConstraint, - self).exportToFilesystemDefinitionDict() - - # There is only one ZODB Constraint class for filesystem - # Constraints CategoryExistence and CategoryAcquiredExistence - # constraints - if self.getUseAcquisition(): - filesystem_definition_dict['type'] = 'CategoryAcquiredExistence' - - filesystem_definition_dict['portal_type'] = \ - Expression(self.getConstraintPortalType()) - - for category in self.getConstraintBaseCategoryList(): - filesystem_definition_dict[category] = 1 - - return filesystem_definition_dict diff --git a/product/ERP5Type/Core/CategoryMembershipArityConstraint.py b/product/ERP5Type/Core/CategoryMembershipArityConstraint.py index 949e53f20ffab1b422a2bb69be7e38d4d7b8e746..a5aed2f8e26ba673b889f4233bb31cf7822cb8c4 100644 --- a/product/ERP5Type/Core/CategoryMembershipArityConstraint.py +++ b/product/ERP5Type/Core/CategoryMembershipArityConstraint.py @@ -54,8 +54,6 @@ class CategoryMembershipArityConstraint(ConstraintMixin): meta_type = 'ERP5 Category Membership Arity Constraint' portal_type = 'Category Membership Arity Constraint' - __compatibility_class_name__ = 'CategoryMembershipArity' - # Declarative security security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) @@ -160,25 +158,3 @@ class CategoryMembershipArityConstraint(ConstraintMixin): zodb_property_dict['max_arity'] = int(max_arity) yield zodb_property_dict - - def exportToFilesystemDefinitionDict(self): - filesystem_definition_dict = super(CategoryMembershipArityConstraint, - self).exportToFilesystemDefinitionDict() - - # There is only one ZODB Constraint class for filesystem - # Constraints CategoryMembershipArity and - # CategoryAcquiredMembershipArity constraints - if self.getUseAcquisition(): - filesystem_definition_dict['type'] = 'CategoryAcquiredMembershipArity' - - filesystem_definition_dict['min_arity'] = str(self.getMinArity()) - - if self.hasMaxArity(): - filesystem_definition_dict['max_arity'] = str(self.getMaxArity()) - - filesystem_definition_dict['portal_type'] = \ - Expression(self.getConstraintPortalType()) - - filesystem_definition_dict['base_category'] = self.getConstraintBaseCategoryList() - - return filesystem_definition_dict diff --git a/product/ERP5Type/Core/CategoryProperty.py b/product/ERP5Type/Core/CategoryProperty.py index 284c8116b39ebfa37cdb88925a068b6485e2ffc6..36aa6251a7e06471acf452387300310b9e6e0fad 100644 --- a/product/ERP5Type/Core/CategoryProperty.py +++ b/product/ERP5Type/Core/CategoryProperty.py @@ -51,15 +51,6 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject): property_sheets = (PropertySheet.SimpleItem, PropertySheet.Reference) - # TODO: REMOVE - security.declareProtected(Permissions.AccessContentsInformation, - 'exportToFilesystemDefinition') - def exportToFilesystemDefinition(self): - """ - Return the filesystem definition of the property - """ - return self.getReference() - security.declareProtected(Permissions.AccessContentsInformation, 'importFromFilesystemDefinition') @classmethod diff --git a/product/ERP5Type/Core/CategoryRelatedMembershipArityConstraint.py b/product/ERP5Type/Core/CategoryRelatedMembershipArityConstraint.py index b0556544f560651449a0db39ca4bee4631b4ff61..451931d2faab239cd3793eef504db813d10b9d94 100644 --- a/product/ERP5Type/Core/CategoryRelatedMembershipArityConstraint.py +++ b/product/ERP5Type/Core/CategoryRelatedMembershipArityConstraint.py @@ -58,8 +58,6 @@ class CategoryRelatedMembershipArityConstraint(CategoryMembershipArityConstraint meta_type = 'ERP5 Category Related Membership Arity Constraint' portal_type = 'Category Related Membership Arity Constraint' - __compatibility_class_name__ = 'CategoryRelatedMembershipArity' - property_sheets = CategoryMembershipArityConstraint.property_sheets + \ (PropertySheet.CategoryRelatedMembershipArityConstraint,) diff --git a/product/ERP5Type/Core/ContentExistenceConstraint.py b/product/ERP5Type/Core/ContentExistenceConstraint.py index a6e7440d693cff414f1404b2ce00700aae80889b..c511a281b5eda882006792b0f5b41298d93645cd 100644 --- a/product/ERP5Type/Core/ContentExistenceConstraint.py +++ b/product/ERP5Type/Core/ContentExistenceConstraint.py @@ -54,8 +54,6 @@ class ContentExistenceConstraint(ConstraintMixin): meta_type = 'ERP5 Content Existence Constraint' portal_type = 'Content Existence Constraint' - __compatibility_class_name__ = 'ContentExistence' - # Declarative security security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) @@ -110,12 +108,3 @@ class ContentExistenceConstraint(ConstraintMixin): portal_type.text or 'python: ' + repr(portal_type) yield dict(constraint_portal_type=constraint_portal_type_str) - - def exportToFilesystemDefinitionDict(self): - filesystem_definition_dict = super(ContentExistenceConstraint, - self).exportToFilesystemDefinitionDict() - - filesystem_definition_dict['portal_type'] = \ - Expression(self.getConstraintPortalType()) - - return filesystem_definition_dict diff --git a/product/ERP5Type/Core/DynamicCategoryProperty.py b/product/ERP5Type/Core/DynamicCategoryProperty.py index 038424cd96ae4cd429778d8d2b5a9bea7b285d76..d5e3cc4c9440aa31fa69a765626fbbd4b0c721c3 100644 --- a/product/ERP5Type/Core/DynamicCategoryProperty.py +++ b/product/ERP5Type/Core/DynamicCategoryProperty.py @@ -50,19 +50,6 @@ class DynamicCategoryProperty(CategoryProperty): property_sheets = (PropertySheet.SimpleItem, PropertySheet.DynamicCategoryProperty) - # TODO: REMOVE - security.declareProtected(Permissions.AccessContentsInformation, - 'exportToFilesystemDefinition') - def exportToFilesystemDefinition(self): - """ - Return the filesystem definition of the property - """ - expression_string = self.getCategoryExpression() - if expression_string is None: - return None - - return Expression(expression_string) - security.declareProtected(Permissions.AccessContentsInformation, 'importFromFilesystemDefinition') @classmethod diff --git a/product/ERP5Type/Core/PropertyExistenceConstraint.py b/product/ERP5Type/Core/PropertyExistenceConstraint.py index 44e686c2c45a0aac8cdc7b6148789285f5f114a4..0e579fcbb9066f2b11f6dff3bbf79e61c95dccc1 100644 --- a/product/ERP5Type/Core/PropertyExistenceConstraint.py +++ b/product/ERP5Type/Core/PropertyExistenceConstraint.py @@ -50,8 +50,6 @@ class PropertyExistenceConstraint(ConstraintMixin): meta_type = 'ERP5 Property Existence Constraint' portal_type = 'Property Existence Constraint' - __compatibility_class_name__ = 'PropertyExistence' - # Declarative security security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) @@ -113,12 +111,3 @@ class PropertyExistenceConstraint(ConstraintMixin): } """ yield dict(constraint_property_list=property_dict.keys()) - - def exportToFilesystemDefinitionDict(self): - filesystem_definition_dict = super(PropertyExistenceConstraint, - self).exportToFilesystemDefinitionDict() - - for constraint_property in self.getConstraintPropertyList(): - filesystem_definition_dict[constraint_property] = None - - return filesystem_definition_dict diff --git a/product/ERP5Type/Core/PropertySheet.py b/product/ERP5Type/Core/PropertySheet.py index 8820d2564e3bb9c562b48aef3e6baf24787fba96..8e0b1d5145e578fb557768a3e9589b0882f7478d 100644 --- a/product/ERP5Type/Core/PropertySheet.py +++ b/product/ERP5Type/Core/PropertySheet.py @@ -48,44 +48,6 @@ class PropertySheet(Folder): security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) - # TODO: REMOVE - security.declareProtected(Permissions.AccessContentsInformation, - 'exportToFilesystemDefinition') - def exportToFilesystemDefinition(self): - """ - Export the ZODB Property Sheet to its filesystem definition as a - tuple (properties, categories, constraints) - """ - properties = [] - constraints = [] - categories = [] - - for item in self.contentValues(): - definition = item.exportToFilesystemDefinition() - - # If a category doesn't have a name yet or the constraint class - # returned is None, then just skip it - if definition is None: - LOG("ERP5Type.Core.PropertySheet", INFO, - "Skipping property with ID '%s' in Property Sheet '%s'" % \ - (item.getId(), self.getId())) - - continue - - portal_type = item.getPortalType() - - if portal_type == "Category Property" or \ - portal_type == "Dynamic Category Property": - categories.append(definition) - - elif portal_type.endswith('Constraint'): - constraints.append(definition) - - else: - properties.append(definition) - - return (properties, categories, constraints) - security.declarePrivate('createAccessorHolder') def createAccessorHolder(self, expression_context, portal): """ diff --git a/product/ERP5Type/Core/PropertyTypeValidityConstraint.py b/product/ERP5Type/Core/PropertyTypeValidityConstraint.py index a37319fd07af26927531c316b30607fa51dccd19..3f748771155262ebc84b8d2c05f5b004c593d5a7 100644 --- a/product/ERP5Type/Core/PropertyTypeValidityConstraint.py +++ b/product/ERP5Type/Core/PropertyTypeValidityConstraint.py @@ -44,8 +44,6 @@ class PropertyTypeValidityConstraint(ConstraintMixin): meta_type = 'ERP5 Property Type Validity Constraint' portal_type = 'Property Type Validity Constraint' - __compatibility_class_name__ = 'PropertyTypeValidity' - property_sheets = ConstraintMixin.property_sheets + \ (PropertySheet.PropertyTypeValidityConstraint,) diff --git a/product/ERP5Type/Core/StandardProperty.py b/product/ERP5Type/Core/StandardProperty.py index 77772158918273d3996e181a3d96c1fa6ab9eab4..e39485589317ba00b9ed915b9d22a761734f2281 100644 --- a/product/ERP5Type/Core/StandardProperty.py +++ b/product/ERP5Type/Core/StandardProperty.py @@ -131,44 +131,6 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject): 'translation_domain', 'string') - # TODO: REMOVE - @staticmethod - def _getExpressionFromString(expression_string): - """ - Get a TALES Expression instance from a string value - """ - if expression_string is None: - return None - - return Expression(expression_string) - - # TODO: REMOVE - security.declareProtected(Permissions.AccessContentsInformation, - 'exportToFilesystemDefinition') - def exportToFilesystemDefinition(self): - """ - Return the filesystem definition of this ZODB property - - NOTE: Only meaningful for testing export of filesystem Property - Sheet to the ZODB - """ - property_default_value = self._getExpressionFromString(self.getPropertyDefault()) - - reference = self.getReference() - if reference: - return {'id': reference, - 'description': self.getDescription(), - 'type': self.getElementaryType(), - 'storage_id': self.getStorageId(), - 'multivalued': self.getMultivalued(), - 'default': property_default_value, - 'range': self.getRange(), - 'preference': self.getPreference(), - 'read_permission': self.getReadPermission(), - 'write_permission': self.getWritePermission(), - 'translatable': self.getTranslatable(), - 'translation_domain': self.getTranslationDomain()} - @classmethod def _asPropertyMap(cls, property_dict): """ diff --git a/product/ERP5Type/Core/TALESConstraint.py b/product/ERP5Type/Core/TALESConstraint.py index a78362f1343826c362ca66422a8b6f4529c04f60..bc005d0eee5e7f6250325b0c5d1f94129775c9d9 100644 --- a/product/ERP5Type/Core/TALESConstraint.py +++ b/product/ERP5Type/Core/TALESConstraint.py @@ -61,8 +61,6 @@ class TALESConstraint(ConstraintMixin): meta_type = 'ERP5 TALES Constraint' portal_type = 'TALES Constraint' - __compatibility_class_name__ = 'TALESConstraint' - property_sheets = ConstraintMixin.property_sheets + \ (PropertySheet.TALESConstraint,) @@ -95,11 +93,3 @@ class TALESConstraint(ConstraintMixin): @staticmethod def _convertFromFilesystemDefinition(expression): yield dict(expression=expression) - - def exportToFilesystemDefinitionDict(self): - filesystem_definition_dict = super(TALESConstraint, - self).exportToFilesystemDefinitionDict() - - filesystem_definition_dict['expression'] = self.getExpression() - - return filesystem_definition_dict diff --git a/product/ERP5Type/mixin/constraint.py b/product/ERP5Type/mixin/constraint.py index 87b45ec2190d41d5444bd3f78aaafe0df31ae6af..a113427f5f1c1f4c646fd9d053551add3408232d 100644 --- a/product/ERP5Type/mixin/constraint.py +++ b/product/ERP5Type/mixin/constraint.py @@ -57,11 +57,6 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate): # importing or exporting from/to filesystem Constraint _message_id_tuple = () - # Store the filesystem name of the ZODB Constraint as there are - # several different naming for filesystem constraints (*only* useful - # for exportToFilesystemDefinitionDict) - __compatibility_class_name__ = None - __allow_access_to_unprotected_subobjects__ = 1 implements( IConstraint, ) @@ -106,27 +101,6 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate): """ return self.checkConsistency(obj, fixit=1, **kw) - security.declareProtected(Permissions.AccessContentsInformation, - 'exportToFilesystemDefinition') - def exportToFilesystemDefinition(self): - """ - Return a temporary copy of the constraint object (with acquisition - wrapping removed) in order to maintain compatibility and be able - to use setDefaultProperties - - NOTE: A filesystem constraint is defined by a dict, then depending - on the 'type' of the constraint, the appropriate class in - ERP5Type.Constraint is instanciated with the dict. This is no - longer needed for ZODB Constraints because they are already - Documents. - - @see exportToFilesystemDefinitionDict() to export a ZODB - Constraint as a dict. - - XXX: remove as soon as the code is stable - """ - return self.asContext().aq_base - def _getExpressionValue(self, obj, expression_string): """ Get the Python value from an Expression string, but check before @@ -219,29 +193,6 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate): constraint_definition_dict.update(base_constraint_definition_dict) context.newContent(**constraint_definition_dict) - security.declareProtected(Permissions.AccessContentsInformation, - 'exportToFilesystemDefinitionDict') - def exportToFilesystemDefinitionDict(self): - """ - Export the ZODB Constraint as a filesystem definition dict, - meaningful *only* for testing that a filesystem Constraint has - been properly converted - - @see exportToFilesystemDefinition() - """ - filesystem_definition_dict = dict( - id=self.getReference(), - description=self.getDescription(), - type=self.__compatibility_class_name__) - - if self.hasTestTalesExpression(): - filesystem_definition_dict['condition'] = self.getTestTalesExpression() - - for message_id in self._message_id_tuple: - filesystem_definition_dict[message_id] = self._getMessage(message_id) - - return filesystem_definition_dict - security.declareProtected(Permissions.AccessContentsInformation, 'applyOnAccessorHolder') def applyOnAccessorHolder(self, accessor_holder, expression_context, portal): diff --git a/product/ERP5Type/tests/testDynamicClassGeneration.py b/product/ERP5Type/tests/testDynamicClassGeneration.py index c34fbf6d5eff04def492b6e687838fce348c922b..a511ade4c8d70dc93d9ac8193c912f404c936a23 100644 --- a/product/ERP5Type/tests/testDynamicClassGeneration.py +++ b/product/ERP5Type/tests/testDynamicClassGeneration.py @@ -1107,228 +1107,6 @@ class TestZodbPropertySheet(ERP5TypeTestCase): self.fail("Creating a Category Expression with syntax error raises "\ "an error") -from Products.CMFCore.Expression import Expression - -class TestZodbImportFilesystemPropertySheet(ERP5TypeTestCase): - """ - Check that importing filesystem Property Sheets into ZODB the same - properties and their values - """ - # The following fields of properties are no longer defined in ZODB - # Property Sheets because they have been deprecated - deprecated_field_name_tuple = ('mode', - 'select_variable', - 'label', - 'acquisition_depends', - 'acquisition_sync_value') - - def afterSetUp(self): - # Mapping between the field name of a property and the default - # value as defined in StandardProperty and AcquiredProperty, - # meaningful because exporting a property relies on accessor which - # returns the default value if the field value is not set - self.filesystem_field_default_value_dict = {} - - from Products.ERP5Type.PropertySheet import StandardProperty, AcquiredProperty - for property_dict in StandardProperty._properties + AcquiredProperty._properties: - try: - self.filesystem_field_default_value_dict[property_dict['id']] = \ - property_dict['default'] - except KeyError: - # Some fields may not defined a default value (such as 'id') - continue - - def _checkPropertyOrConstraintField(self, - property_sheet_name, - field_name, - filesystem_value, - zodb_value): - """ - Check whether the given filesystem property or constraint value - and the given ZODB property value are equal - """ - if isinstance(zodb_value, (list, tuple)) and \ - isinstance(filesystem_value, (list, tuple)): - self.failIfDifferentSet( - zodb_value, filesystem_value, - msg="%s: %s: filesystem value: %s, ZODB value: %s" % \ - (property_sheet_name, field_name, filesystem_value, zodb_value)) - - else: - # In ZODB Property Sheets, we have to get the TALES Expression - # as a string for properties, which used to be Expression in - # filesystem Property Sheets or are now Expression (because they - # used to be defined as Python types, such as tuple or int...) - if isinstance(zodb_value, Expression): - # In filesystem Property Sheets, acquisition_portal_type and - # portal_type, might be instances of Expression - if isinstance(filesystem_value, Expression): - zodb_value = zodb_value.text - filesystem_value = filesystem_value.text - # Otherwise, just convert the filesystem value to a TALES - # Expression string - else: - zodb_value = zodb_value.text - filesystem_value = 'python: ' + repr(filesystem_value) - - self.failUnlessEqual( - zodb_value, filesystem_value, - msg="%s: %s: filesystem value: %s, ZODB value: %s" % \ - (property_sheet_name, field_name, filesystem_value, - zodb_value)) - - def _checkPropertyOrConstraintDefinitionTuple(self, - property_sheet_name, - filesystem_property_tuple, - zodb_property_tuple): - """ - Check whether all properties or constraints have been properly - converted from the filesystem to the ZODB Property Sheet - """ - # Check whether all the properties or constraints are present in - # the given ZODB Property Sheet - self.assertEqual( - len(filesystem_property_tuple), len(zodb_property_tuple), - msg="%s: too many properties: filesystem: %s, ZODB: %s" % \ - (property_sheet_name, filesystem_property_tuple, zodb_property_tuple)) - - # Map filesystem property or constraint IDs to their definition - filesystem_property_id_dict = {} - for property_dict in filesystem_property_tuple: - filesystem_property_id_dict[property_dict['id']] = property_dict - - # Check each property or constraint defined in ZODB against the - # filesystem dict defined before - for zodb_property_dict in zodb_property_tuple: - # Meaningful to ensure that there is no missing field within a - # property or constraint - validated_field_counter = 0 - - filesystem_property_dict = \ - filesystem_property_id_dict[zodb_property_dict['id']] - - # Check each property or constraint field - for field_name, zodb_value in zodb_property_dict.iteritems(): - if field_name in filesystem_property_dict: - self._checkPropertyOrConstraintField( - property_sheet_name, field_name, - filesystem_property_dict[field_name], - zodb_value) - - # As we are using accessors when exporting the ZODB Property - # Sheet to its filesystem definition, there may be additional - # fields set to their default value - elif field_name in self.filesystem_field_default_value_dict: - self.assertEqual( - self.filesystem_field_default_value_dict[field_name], - zodb_value, - msg="%s: Wrong default value %s for %s" % \ - (property_sheet_name, zodb_value, field_name)) - - validated_field_counter += 1 - - if len(filesystem_property_dict) != validated_field_counter: - missing_field_name_list = [ - k for k in filesystem_property_dict \ - if k not in zodb_property_dict and \ - k not in self.deprecated_field_name_tuple ] - - self.assertTrue( - len(missing_field_name_list) == 0, - msg="%s: missing fields: %s: filesystem: %s, ZODB: %s" % \ - (property_sheet_name, missing_field_name_list, - filesystem_property_dict, zodb_property_dict)) - - def _checkCategoryTuple(self, - property_sheet_name, - filesystem_category_tuple, - zodb_category_tuple): - """ - Check whether all categories have been properly converted - """ - # There should be the same number of categories - self.assertEqual( - len(filesystem_category_tuple), len(zodb_category_tuple), - msg="%s: Missing/added categories: filesystem: %s, ZODB: %s" % \ - (property_sheet_name, filesystem_category_tuple, zodb_category_tuple)) - - # Some Categories are instance of Expression, so compute a list of - # categories as strings - zodb_category_list = [ - isinstance(category, Expression) and category.text or category \ - for category in zodb_category_tuple ] - - # Now, compare filesystem categories with ZODB - for category in filesystem_category_tuple: - if isinstance(category, Expression): - category = category.text - - self.assertTrue( - category in zodb_category_list, - msg="%s: Missing category %s: ZODB: %s" % \ - (property_sheet_name, category, zodb_category_list)) - - def testZodbImportPropertySheet(self): - """ - Create Property Sheets on portal_property_sheets from their - definition on the filesystem and then test that they are - equivalent - """ - portal = self.getPortalObject().portal_property_sheets - - from Products.ERP5PropertySheetLegacy import PropertySheet - import os - - property_sheets_tool = self.portal.portal_property_sheets - property_sheet_legacy_class_dict = {} - for module in os.listdir(os.path.dirname(PropertySheet.__file__)): - if module == '__init__.py' or module[-3:] != '.py': - continue - - filename = module[:-3] - - property_sheet_legacy_class_dict[filename] = \ - getattr(__import__(filename, locals(), globals()), filename) - - # Get all the property sheets defined on the filesystem - for name, klass in property_sheet_legacy_class_dict.iteritems(): - filesystem_property_sheet = klass - property_sheet_name = name - - # Rename the filesystem Property Sheet class to avoid clashing - # with existing Property Sheets in portal_property_sheets - filesystem_property_sheet.__name__ = "%s_%s" % \ - (self.__class__.__name__, property_sheet_name) - - zodb_property_sheet = PropertySheetDocument.importFromFilesystemDefinition( - property_sheets_tool, filesystem_property_sheet) - - self.assertTrue(filesystem_property_sheet.__name__ in \ - property_sheets_tool.objectIds()) - - zodb_property_tuple, zodb_category_tuple, zodb_constraint_class_tuple = \ - zodb_property_sheet.exportToFilesystemDefinition() - - self._checkPropertyOrConstraintDefinitionTuple( - property_sheet_name, - getattr(filesystem_property_sheet, '_properties', []), - zodb_property_tuple) - - self._checkCategoryTuple(property_sheet_name, - getattr(filesystem_property_sheet, - '_categories', []), - zodb_category_tuple) - - self._checkPropertyOrConstraintDefinitionTuple( - property_sheet_name, getattr(filesystem_property_sheet, - '_constraints', []), - [ zodb_constraint_class.exportToFilesystemDefinitionDict() \ - for zodb_constraint_class in zodb_constraint_class_tuple ]) - -TestZodbImportFilesystemPropertySheet = skip( - "ERP5PropertySheetLegacy is now obsolete")( - TestZodbImportFilesystemPropertySheet) - def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestPortalTypeClass))