From a6ebc1e645e7dd5f737c6932ced40e94be1427de Mon Sep 17 00:00:00 2001 From: Alexandre Boeglin <alex@nexedi.com> Date: Mon, 8 May 2006 17:51:41 +0000 Subject: [PATCH] generate DefaultGetter and DefaultSetter for AcquiredProperties, using the same behaviour as Getter and Setter. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7115 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Accessor/AcquiredProperty.py | 5 ++ product/ERP5Type/Utils.py | 51 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/product/ERP5Type/Accessor/AcquiredProperty.py b/product/ERP5Type/Accessor/AcquiredProperty.py index 1867685c43..0b3ea52802 100644 --- a/product/ERP5Type/Accessor/AcquiredProperty.py +++ b/product/ERP5Type/Accessor/AcquiredProperty.py @@ -99,6 +99,8 @@ class Getter(Method): psyco.bind(__call__) +DefaultGetter = Getter + class Setter(Method): """ Gets the default reference of a relation @@ -168,3 +170,6 @@ class Setter(Method): o.setProperty(self._acquired_property, value, *args, **kw) else: o._setProperty(self._acquired_property, value, *args, **kw) + +DefaultSetter = Setter + diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py index 3834ac270d..b27e9e4f4a 100644 --- a/product/ERP5Type/Utils.py +++ b/product/ERP5Type/Utils.py @@ -1365,6 +1365,7 @@ def createDefaultAccessors(property_holder, id, prop = None, if prop.has_key('acquired_property_id'): for aq_id in prop['acquired_property_id']: composed_id = "%s_%s" % (id, aq_id) + # Getter # print "Set composed_id accessor %s" % composed_id accessor_name = 'get' + UpperCase(composed_id) # print "Set accessor_name accessor %s" % accessor_name @@ -1391,9 +1392,32 @@ def createDefaultAccessors(property_holder, id, prop = None, if not hasattr(property_holder, accessor_name) or prop.get('override',0): setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name)) # Default Getter - ################# NOT YET + accessor_name = 'getDefault' + UpperCase(composed_id) + base_accessor = AcquiredProperty.DefaultGetter(accessor_name, + composed_id, + prop['type'], + prop['portal_type'], + aq_id, + prop['acquisition_base_category'], + prop['acquisition_portal_type'], + prop['acquisition_accessor_id'], + prop.get('acquisition_copy_value',0), + prop.get('acquisition_mask_value',0), + prop.get('acquisition_sync_value',0), + storage_id = prop.get('storage_id'), + alt_accessor_id = prop.get('alt_accessor_id'), + is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)), + is_tales_type = (prop['type'] == 'tales') + ) + if not hasattr(property_holder, accessor_name) or prop.get('override',0): + setattr(property_holder, accessor_name, base_accessor) + property_holder.security.declareProtected( read_permission, accessor_name ) + accessor_name = '_baseGetDefault' + UpperCase(id) + if not hasattr(property_holder, accessor_name) or prop.get('override',0): + setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name)) # List Getter ################# NOT YET + # Setter accessor_name = 'set' + UpperCase(composed_id) base_accessor = AcquiredProperty.Setter(accessor_name, composed_id, @@ -1419,7 +1443,30 @@ def createDefaultAccessors(property_holder, id, prop = None, if not hasattr(property_holder, accessor_name) or prop.get('override',0): setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name)) # Default Getter - ################# NOT YET + accessor_name = 'setDefault' + UpperCase(composed_id) + base_accessor = AcquiredProperty.DefaultSetter(accessor_name, + composed_id, + prop['type'], + prop['portal_type'], + aq_id, + prop['acquisition_base_category'], + prop['acquisition_portal_type'], + prop['acquisition_accessor_id'], + prop.get('acquisition_copy_value',0), + prop.get('acquisition_mask_value',0), + prop.get('acquisition_sync_value',0), + storage_id = prop.get('storage_id'), + alt_accessor_id = prop.get('alt_accessor_id'), + is_list_type = (prop['type'] in list_types or prop.get('multivalued', 0)), + is_tales_type = (prop['type'] == 'tales'), + reindex = 1 + ) + if not hasattr(property_holder, accessor_name) or prop.get('override',0): + setattr(property_holder, accessor_name, base_accessor) + property_holder.security.declareProtected( write_permission, accessor_name ) + accessor_name = 'baseSetDefault' + UpperCase(id) + if not hasattr(property_holder, accessor_name) or prop.get('override',0): + setattr(property_holder, accessor_name, base_accessor.dummy_copy(accessor_name)) # List Getter ################# NOT YET -- 2.30.9