Commit be364214 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Add static getters for StandardProperty, AcquiredProperty and

CategoryProperty documents for bootstrap with only ZODB Property
Sheets.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39941 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3afe785c
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.Core.StandardProperty import StandardProperty 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): class AcquiredProperty(StandardProperty):
""" """
...@@ -62,16 +63,61 @@ class AcquiredProperty(StandardProperty): ...@@ -62,16 +63,61 @@ class AcquiredProperty(StandardProperty):
StandardProperty._expression_attribute_tuple + \ StandardProperty._expression_attribute_tuple + \
('acquisition_portal_type', 'content_portal_type') ('acquisition_portal_type', 'content_portal_type')
@staticmethod # Define getters for the property. This is necessary for bootstrap
def _convertValueToTalesExpression(value): # as a Standard Property uses SimpleItem, defined with Acquired
""" # Properties
Convert a string value to a TALES expression for attributes listed #
in '_expression_attribute_tuple' # There is no need to define the setter as this static definition of
""" # the getter is only meaningful for the Acquired Properties defined
if value is None: # within an Acquired Property.
return None 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')
return Expression(value) getContentTranslationAcquiredPropertyIdList = ListGetter(
'getContentTranslationAcquiredPropertyIdList',
'content_translation_acquired_property_id',
'lines')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition') 'exportToFilesystemDefinition')
...@@ -85,12 +131,12 @@ class AcquiredProperty(StandardProperty): ...@@ -85,12 +131,12 @@ class AcquiredProperty(StandardProperty):
filesystem_property_dict.update( filesystem_property_dict.update(
{'acquisition_base_category': self.getAcquisitionBaseCategoryList(), {'acquisition_base_category': self.getAcquisitionBaseCategoryList(),
'acquisition_object_id': self.getAcquisitionObjectIdList(), 'acquisition_object_id': self.getAcquisitionObjectIdList(),
'acquisition_portal_type': self._convertValueToTalesExpression(self.getAcquisitionPortalType()), 'acquisition_portal_type': self.getAcquisitionPortalType(),
'acquisition_accessor_id': self.getAcquisitionAccessorId(), 'acquisition_accessor_id': self.getAcquisitionAccessorId(),
'alt_accessor_id': self.getAltAccessorIdList(), 'alt_accessor_id': self.getAltAccessorIdList(),
'acquisition_copy_value': self.getAcquisitionCopyValue(), 'acquisition_copy_value': self.getAcquisitionCopyValue(),
'acquisition_mask_value': self.getAcquisitionMaskValue(), 'acquisition_mask_value': self.getAcquisitionMaskValue(),
'portal_type': self._convertValueToTalesExpression(self.getContentPortalType()), 'portal_type': self.getContentPortalType(),
'acquired_property_id': self.getContentAcquiredPropertyIdList(), 'acquired_property_id': self.getContentAcquiredPropertyIdList(),
'translation_acquired_property_id': self.getContentTranslationAcquiredPropertyIdList()}) 'translation_acquired_property_id': self.getContentTranslationAcquiredPropertyIdList()})
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Accessor.Base import Getter as BaseGetter
class CategoryProperty(XMLObject): class CategoryProperty(XMLObject):
""" """
...@@ -44,6 +45,9 @@ class CategoryProperty(XMLObject): ...@@ -44,6 +45,9 @@ class CategoryProperty(XMLObject):
property_sheets = (PropertySheet.SimpleItem, property_sheets = (PropertySheet.SimpleItem,
PropertySheet.Reference) PropertySheet.Reference)
getReference = BaseGetter('getReference', 'reference', 'string',
storage_id='default_reference')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition') 'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self): def exportToFilesystemDefinition(self):
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Accessor.Base import Getter as BaseGetter
class StandardProperty(XMLObject): class StandardProperty(XMLObject):
""" """
...@@ -57,6 +57,61 @@ class StandardProperty(XMLObject): ...@@ -57,6 +57,61 @@ class StandardProperty(XMLObject):
# ZODB name of attributes whose value is a TALES Expression string # ZODB name of attributes whose value is a TALES Expression string
_expression_attribute_tuple = ('property_default',) _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, security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition') 'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self): def exportToFilesystemDefinition(self):
...@@ -68,7 +123,7 @@ class StandardProperty(XMLObject): ...@@ -68,7 +123,7 @@ class StandardProperty(XMLObject):
'type': self.getElementaryType(), 'type': self.getElementaryType(),
'storage_id': self.getStorageId(), 'storage_id': self.getStorageId(),
'multivalued': self.getMultivalued(), 'multivalued': self.getMultivalued(),
'default': Expression(self.getPropertyDefault()), 'default': self.getPropertyDefault(),
'range': self.getRange(), 'range': self.getRange(),
'preference': self.getPreference(), 'preference': self.getPreference(),
'read_permission': self.getReadPermission(), 'read_permission': self.getReadPermission(),
......
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