Commit 5de789b5 authored by Sebastien Robin's avatar Sebastien Robin

- stop doing strange things with setReference on properties

- use Reference Propertysheet instead of add reference property
  in another propertysheet

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43833 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ac69c319
......@@ -48,7 +48,8 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
property_sheets = (PropertySheet.SimpleItem,)
property_sheets = (PropertySheet.SimpleItem,
PropertySheet.Reference)
security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition')
......@@ -66,7 +67,7 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject):
Set the Reference from a filesystem definition of a property
"""
return context.newContent(portal_type=cls.portal_type,
reference=category_name)
id=category_name + cls.getIdAsReferenceSuffix())
getter_definition_dict = {
# normal accessors
......
......@@ -46,12 +46,12 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
property_sheets = (PropertySheet.SimpleItem,
PropertySheet.StandardProperty,
PropertySheet.Reference,
PropertySheet.TranslatableProperty)
# Names mapping between filesystem to ZODB property, only meaningful
# when importing a property from its filesystem definition
_name_mapping_filesystem_to_zodb_dict = {'id': 'reference',
'type': 'elementary_type',
_name_mapping_filesystem_to_zodb_dict = {'type': 'elementary_type',
'default': 'property_default'}
# ZODB name of attributes whose value is a TALES Expression string
......@@ -165,6 +165,10 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
value = isinstance(value, Expression) and \
value.text or 'python: ' + repr(value)
# set correctly the id by following naming conventions
if zodb_property_name == 'id':
value += cls.getIdAsReferenceSuffix()
zodb_property_dict[zodb_property_name] = value
return zodb_property_dict
......
......@@ -61,7 +61,8 @@ def IdAsReferenceMixin(suffix):
security.declareProtected(Permissions.AccessContentsInformation,
'getIdAsReferenceSuffix')
def getIdAsReferenceSuffix(self):
@staticmethod
def getIdAsReferenceSuffix():
return suffix
security.declareProtected(Permissions.AccessContentsInformation,
......@@ -70,18 +71,6 @@ def IdAsReferenceMixin(suffix):
id = self.id
if id[suffix_index:] == suffix:
return id[:suffix_index]
# BBB
reference = self.__dict__.get('default_reference')
if reference:
transaction.get().addBeforeCommitHook(self.__migrate)
return reference
return default
def _setReference(self, value):
self.__dict__.pop('default_reference', None) # BBB
self.setId(value + suffix)
security.declareProtected(Permissions.ModifyPortalContent, 'setReference')
setReference = _setReference
return self._baseGetReference(default=default)
return IdAsReferenceMixin
......@@ -66,6 +66,7 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate):
implements( IConstraint, )
property_sheets = (PropertySheet.SimpleItem,
PropertySheet.Reference,
PropertySheet.Predicate)
def _getMessage(self, message_id):
......@@ -186,8 +187,9 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate):
base_constraint_definition_dict['portal_type'] = cls.portal_type
base_constraint_definition_dict['reference'] = \
filesystem_definition_copy_dict.pop('id')
base_constraint_definition_dict['id'] = \
filesystem_definition_copy_dict.pop('id') + \
cls.getIdAsReferenceSuffix()
base_constraint_definition_dict['description'] = \
filesystem_definition_copy_dict.pop('description', '')
......
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