Commit 9dbedf74 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Apply API changes on StandardProperty for per-document accessors

generation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43883 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5d05b12f
...@@ -51,6 +51,7 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject): ...@@ -51,6 +51,7 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject):
property_sheets = (PropertySheet.SimpleItem, property_sheets = (PropertySheet.SimpleItem,
PropertySheet.Reference) PropertySheet.Reference)
# TODO: REMOVE
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'exportToFilesystemDefinition') 'exportToFilesystemDefinition')
def exportToFilesystemDefinition(self): def exportToFilesystemDefinition(self):
...@@ -143,20 +144,22 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject): ...@@ -143,20 +144,22 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject):
} }
@classmethod @classmethod
def applyPropertyOnAccessorHolder(cls, def applyDefinitionOnAccessorHolder(cls,
accessor_holder, accessor_holder,
category_id, category_id,
category_tool): portal):
if category_tool is None: try:
return cat_object = portal.portal_categories._getOb(category_id)
except AttributeError:
cat_object = category_tool.get(category_id, None) if portal.hasObject('portal_categories'):
if cat_object is None:
LOG("ERP5Type.Core.CategoryProperty", WARNING, LOG("ERP5Type.Core.CategoryProperty", WARNING,
"Base Category %r is missing. Accessors can not be generated." % \ "Base Category %r is missing. Accessors can not be generated." % \
category_id) category_id)
return return
except TypeError:
# category_id is None
raise ValueError("Invalid category reference")
# Create free text accessors. # Create free text accessors.
# XXX These are only for backward compatibility. # XXX These are only for backward compatibility.
...@@ -171,11 +174,16 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject): ...@@ -171,11 +174,16 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject):
'property_default': '', 'property_default': '',
'multivalued': False, 'multivalued': False,
'storage_id': storage_id, 'storage_id': storage_id,
'range': False,
'translatable': False,
'description': 'free text to specify %s' % category_id,
'read_permission': Permissions.AccessContentsInformation, 'read_permission': Permissions.AccessContentsInformation,
'write_permission': Permissions.ModifyPortalContent} 'write_permission': Permissions.ModifyPortalContent}
StandardProperty._applyOnAccessorHolder(property_dict, accessor_holder, StandardProperty.applyDefinitionOnAccessorHolder(property_dict,
category_tool.getPortalObject()) accessor_holder,
portal,
do_register=False)
# Get read and write permission # Get read and write permission
read_permission = Permissions.__dict__.get(cat_object.getReadPermission(), read_permission = Permissions.__dict__.get(cat_object.getReadPermission(),
...@@ -226,8 +234,6 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject): ...@@ -226,8 +234,6 @@ class CategoryProperty(IdAsReferenceMixin('_category'), XMLObject):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'applyOnAccessorHolder') 'applyOnAccessorHolder')
def applyOnAccessorHolder(self, accessor_holder, expression_context, portal): def applyOnAccessorHolder(self, accessor_holder, expression_context, portal):
reference = self.getReference() self.applyDefinitionOnAccessorHolder(accessor_holder,
if reference is not None: self.getReference(),
self.applyPropertyOnAccessorHolder(accessor_holder, portal)
reference,
getattr(portal, 'portal_categories', None))
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