Commit 377b34e3 authored by Arnaud Fontaine's avatar Arnaud Fontaine

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.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40224 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 06718775
......@@ -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()})
......
......@@ -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(),
......
......@@ -255,6 +255,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
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(ERP5TypeTestCase):
# 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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment