[Erp5-report] r40224 arnaud.fontaine - in /erp5/trunk/products/ERP5Type: Core/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Nov 12 07:12:25 CET 2010
Author: arnaud.fontaine
Date: Fri Nov 12 07:12:24 2010
New Revision: 40224
URL: http://svn.erp5.org?rev=40224&view=rev
Log:
Fix TALES property getters for ZODB Property Sheets.
These getters must return a string rather than the evaluated
Expression, otherwise it means that only the result of the Expression
is displayed in the view rather than the TALES Expression itself.
Modified:
erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py
erp5/trunk/products/ERP5Type/Core/StandardProperty.py
erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
Modified: erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py?rev=40224&r1=40223&r2=40224&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py [utf8] Fri Nov 12 07:12:24 2010
@@ -79,11 +79,12 @@ class AcquiredProperty(StandardProperty)
'acquisition_object_id',
'lines')
- # Use a tales type here, so the TALES expression instance is created
- # when actually calling the function
+ # Define as a TALES expression string, use for Expression
+ # instanciation when exporting the property to the filesystem
+ # definition
getAcquisitionPortalType = BaseGetter('getAcquisitionPortalType',
'acquisition_portal_type',
- 'tales')
+ 'string')
getAcquisitionAccessorId = BaseGetter('getAcquisitionAccessorId',
'acquisition_accessor_id',
@@ -103,11 +104,12 @@ class AcquiredProperty(StandardProperty)
'boolean',
default=False)
- # Use a tales type here, so the TALES expression instance is created
- # when actually calling the function
+ # Define as a TALES expression string, use for Expression
+ # instanciation when exporting the property to the filesystem
+ # definition
getContentPortalType = BaseGetter('getContentPortalType',
'content_portal_type',
- 'tales')
+ 'string')
getContentAcquiredPropertyIdList = ListGetter(
'getContentAcquiredPropertyIdList',
@@ -128,15 +130,21 @@ class AcquiredProperty(StandardProperty)
filesystem_property_dict = \
StandardProperty.exportToFilesystemDefinition(self)
+ acquisition_portal_type_value = self._convertValueToTalesExpression(
+ self.getAcquisitionPortalType())
+
+ portal_type_value = self._convertValueToTalesExpression(
+ self.getContentPortalType())
+
filesystem_property_dict.update(
{'acquisition_base_category': self.getAcquisitionBaseCategoryList(),
'acquisition_object_id': self.getAcquisitionObjectIdList(),
- 'acquisition_portal_type': self.getAcquisitionPortalType(),
+ 'acquisition_portal_type': acquisition_portal_type_value,
'acquisition_accessor_id': self.getAcquisitionAccessorId(),
'alt_accessor_id': self.getAltAccessorIdList(),
'acquisition_copy_value': self.getAcquisitionCopyValue(),
'acquisition_mask_value': self.getAcquisitionMaskValue(),
- 'portal_type': self.getContentPortalType(),
+ 'portal_type': portal_type_value,
'acquired_property_id': self.getContentAcquiredPropertyIdList(),
'translation_acquired_property_id': self.getContentTranslationAcquiredPropertyIdList()})
Modified: erp5/trunk/products/ERP5Type/Core/StandardProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/StandardProperty.py?rev=40224&r1=40223&r2=40224&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/StandardProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/StandardProperty.py [utf8] Fri Nov 12 07:12:24 2010
@@ -86,10 +86,11 @@ class StandardProperty(XMLObject):
getMultivalued = BaseGetter('getMultivalued', 'multivalued', 'boolean',
default=False)
- # Use a tales type here, so the TALES expression instance is created
- # when actually calling the function
+ # Define as a TALES expression string, use for Expression
+ # instanciation when exporting the property to the filesystem
+ # definition
getPropertyDefault = BaseGetter('getPropertyDefault', 'property_default',
- 'tales')
+ 'string')
getRange = BaseGetter('getRange', 'range', 'boolean', default=False)
@@ -112,18 +113,32 @@ class StandardProperty(XMLObject):
'translation_domain',
'string')
+ @staticmethod
+ def _convertValueToTalesExpression(value):
+ """
+ Convert a string value to a TALES expression for attributes listed
+ in '_expression_attribute_tuple'
+ """
+ if value is None:
+ return None
+
+ return Expression(value)
+
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self):
"""
Return the filesystem definition of this ZODB property
"""
+ property_default_value = self._convertValueToTalesExpression(
+ self.getPropertyDefault())
+
return {'id': self.getReference(),
'description': self.getDescription(),
'type': self.getElementaryType(),
'storage_id': self.getStorageId(),
'multivalued': self.getMultivalued(),
- 'default': self.getPropertyDefault(),
+ 'default': property_default_value,
'range': self.getRange(),
'preference': self.getPreference(),
'read_permission': self.getReadPermission(),
Modified: erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py?rev=40224&r1=40223&r2=40224&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] Fri Nov 12 07:12:24 2010
@@ -255,6 +255,7 @@ class TestZodbPropertySheet(ERP5TypeTest
return self.test_property_sheet.newContent(
portal_type='Standard Property',
reference='test_standard_property_' + operation_type,
+ property_default='python: "test_default_value"',
elementary_type='string')
def _newAcquiredProperty(self, operation_type):
@@ -478,6 +479,9 @@ class TestZodbPropertySheet(ERP5TypeTest
# Standard Property
self.assertHasAttribute(new_person, 'setTestStandardPropertyAssign')
+ self.assertEquals(new_person.getTestStandardPropertyAssign(),
+ "test_default_value")
+
new_person.setTestStandardPropertyAssign('value')
self.assertEquals(new_person.getTestStandardPropertyAssign(), 'value')
More information about the Erp5-report
mailing list