[Erp5-report] r39941 arnaud.fontaine - /erp5/trunk/products/ERP5Type/Core/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Nov 5 07:06:42 CET 2010
Author: arnaud.fontaine
Date: Fri Nov 5 07:06:41 2010
New Revision: 39941
URL: http://svn.erp5.org?rev=39941&view=rev
Log:
Add static getters for StandardProperty, AcquiredProperty and
CategoryProperty documents for bootstrap with only ZODB Property
Sheets.
Modified:
erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py
erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
erp5/trunk/products/ERP5Type/Core/StandardProperty.py
Modified: erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py?rev=39941&r1=39940&r2=39941&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/AcquiredProperty.py [utf8] Fri Nov 5 07:06:41 2010
@@ -28,9 +28,10 @@
from AccessControl import ClassSecurityInfo
from Products.CMFCore.Expression import Expression
-
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.Core.StandardProperty import StandardProperty
+from Products.ERP5Type.Accessor.Base import Getter as BaseGetter
+from Products.ERP5Type.Accessor.List import ListGetter
class AcquiredProperty(StandardProperty):
"""
@@ -62,16 +63,61 @@ class AcquiredProperty(StandardProperty)
StandardProperty._expression_attribute_tuple + \
('acquisition_portal_type', 'content_portal_type')
- @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)
+ # Define getters for the property. This is necessary for bootstrap
+ # as a Standard Property uses SimpleItem, defined with Acquired
+ # Properties
+ #
+ # There is no need to define the setter as this static definition of
+ # the getter is only meaningful for the Acquired Properties defined
+ # within an Acquired Property.
+ getAcquisitionBaseCategoryList = ListGetter(
+ 'getAcquisitionBaseCategoryList',
+ 'acquisition_base_category',
+ 'lines')
+
+ getAcquisitionObjectIdList = ListGetter('getAcquisitionObjectIdList',
+ 'acquisition_object_id',
+ 'lines')
+
+ # Use a tales type here, so the TALES expression instance is created
+ # when actually calling the function
+ getAcquisitionPortalType = BaseGetter('getAcquisitionPortalType',
+ 'acquisition_portal_type',
+ 'tales')
+
+ getAcquisitionAccessorId = BaseGetter('getAcquisitionAccessorId',
+ 'acquisition_accessor_id',
+ 'string')
+
+ getAltAccessorIdList = ListGetter('getAltAccessorIdList',
+ 'alt_accessor_id',
+ 'lines')
+
+ getAcquisitionCopyValue = BaseGetter('getAcquisitionCopyValue',
+ 'acquisition_copy_value',
+ 'boolean',
+ default=False)
+
+ getAcquisitionMaskValue = BaseGetter('getAcquisitionMaskValue',
+ 'acquisition_mask_value',
+ 'boolean',
+ default=False)
+
+ # Use a tales type here, so the TALES expression instance is created
+ # when actually calling the function
+ getContentPortalType = BaseGetter('getContentPortalType',
+ 'content_portal_type',
+ 'tales')
+
+ getContentAcquiredPropertyIdList = ListGetter(
+ 'getContentAcquiredPropertyIdList',
+ 'content_acquired_property_id',
+ 'lines')
+
+ getContentTranslationAcquiredPropertyIdList = ListGetter(
+ 'getContentTranslationAcquiredPropertyIdList',
+ 'content_translation_acquired_property_id',
+ 'lines')
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
@@ -85,12 +131,12 @@ class AcquiredProperty(StandardProperty)
filesystem_property_dict.update(
{'acquisition_base_category': self.getAcquisitionBaseCategoryList(),
'acquisition_object_id': self.getAcquisitionObjectIdList(),
- 'acquisition_portal_type': self._convertValueToTalesExpression(self.getAcquisitionPortalType()),
+ 'acquisition_portal_type': self.getAcquisitionPortalType(),
'acquisition_accessor_id': self.getAcquisitionAccessorId(),
'alt_accessor_id': self.getAltAccessorIdList(),
'acquisition_copy_value': self.getAcquisitionCopyValue(),
'acquisition_mask_value': self.getAcquisitionMaskValue(),
- 'portal_type': self._convertValueToTalesExpression(self.getContentPortalType()),
+ 'portal_type': self.getContentPortalType(),
'acquired_property_id': self.getContentAcquiredPropertyIdList(),
'translation_acquired_property_id': self.getContentTranslationAcquiredPropertyIdList()})
Modified: erp5/trunk/products/ERP5Type/Core/CategoryProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CategoryProperty.py?rev=39941&r1=39940&r2=39941&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CategoryProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/CategoryProperty.py [utf8] Fri Nov 5 07:06:41 2010
@@ -29,6 +29,7 @@
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
+from Products.ERP5Type.Accessor.Base import Getter as BaseGetter
class CategoryProperty(XMLObject):
"""
@@ -44,6 +45,9 @@ class CategoryProperty(XMLObject):
property_sheets = (PropertySheet.SimpleItem,
PropertySheet.Reference)
+ getReference = BaseGetter('getReference', 'reference', 'string',
+ storage_id='default_reference')
+
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self):
Modified: erp5/trunk/products/ERP5Type/Core/StandardProperty.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/StandardProperty.py?rev=39941&r1=39940&r2=39941&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/StandardProperty.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/StandardProperty.py [utf8] Fri Nov 5 07:06:41 2010
@@ -28,9 +28,9 @@
from AccessControl import ClassSecurityInfo
from Products.CMFCore.Expression import Expression
-
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
+from Products.ERP5Type.Accessor.Base import Getter as BaseGetter
class StandardProperty(XMLObject):
"""
@@ -57,6 +57,61 @@ class StandardProperty(XMLObject):
# ZODB name of attributes whose value is a TALES Expression string
_expression_attribute_tuple = ('property_default',)
+ # Define getters for the property. This is necessary for bootstrap
+ # as a Standard Property is defined by Standard Properties which
+ # also depends on Property Sheets defined by Standard Properties.
+ #
+ # There is no need to define the setter as this static definition of
+ # the getter is only meaningful for the Standard Properties defined
+ # within an Standard Property.
+ getReference = BaseGetter('getReference', 'reference', 'string',
+ storage_id='default_reference')
+
+ getDescription = BaseGetter('getDescription', 'description', 'string',
+ default='')
+
+ def getElementaryType(self):
+ """
+ Define this getter manually as it is not possible to rely on
+ CategoryTool during the bootstrap
+ """
+ for category in self.__dict__.get('categories', ()):
+ if category.startswith('elementary_type/'):
+ return category.split('elementary_type/')[1]
+
+ raise AttributeError("%s: Could not get elementary_type" % self)
+
+ getStorageId = BaseGetter('getStorageId', 'storage_id', 'string')
+
+ getMultivalued = BaseGetter('getMultivalued', 'multivalued', 'boolean',
+ default=False)
+
+ # Use a tales type here, so the TALES expression instance is created
+ # when actually calling the function
+ getPropertyDefault = BaseGetter('getPropertyDefault', 'property_default',
+ 'tales')
+
+ getRange = BaseGetter('getRange', 'range', 'boolean', default=False)
+
+ getPreference = BaseGetter('getPreference', 'preference', 'boolean',
+ default=False)
+
+ getReadPermission = BaseGetter(
+ 'getReadPermission', 'read_permission', 'string',
+ default=Permissions.AccessContentsInformation)
+
+ getWritePermission = BaseGetter('getWritePermission',
+ 'write_permission',
+ 'string',
+ default=Permissions.ModifyPortalContent)
+
+ getTranslatable = BaseGetter('getTranslatable', 'translatable', 'boolean',
+ default=False)
+
+ getTranslationDomain = BaseGetter('getTranslationDomain',
+ 'translation_domain',
+ 'string')
+
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self):
@@ -68,7 +123,7 @@ class StandardProperty(XMLObject):
'type': self.getElementaryType(),
'storage_id': self.getStorageId(),
'multivalued': self.getMultivalued(),
- 'default': Expression(self.getPropertyDefault()),
+ 'default': self.getPropertyDefault(),
'range': self.getRange(),
'preference': self.getPreference(),
'read_permission': self.getReadPermission(),
More information about the Erp5-report
mailing list