Commit eca805c4 authored by Jean-Paul Smets's avatar Jean-Paul Smets

A new accessor family is provided : Alias. The purpose of Alias accessors is...

A new accessor family is provided : Alias. The purpose of Alias accessors is to reduce the number of independent accessors and try to factorise accessors. With Aliases, overloading the default behaviour of aliases may become easier. For example, the method setFirstName will now invoke _setFirstName and then reindex. This way, an interaction method will only need to use _setFirstName  as trigger. If the user wants to overload _setFirstName , it becomes possible without having to overload setFirstName at the same time.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15678 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9fbcbb83
...@@ -50,15 +50,16 @@ class Accessor(Method): ...@@ -50,15 +50,16 @@ class Accessor(Method):
def dummy_copy(self, id): def dummy_copy(self, id):
# Copy an accessor and change its id/name # Copy an accessor and change its id/name
#self.__call__ = None
#try:
# clone_instance = self.__class__(*self.__getinitargs__())
#except:
# LOG('dummy_copy', 0, '%r could not be generated with %r' % (id, self.__class__), error=sys.exc_info())
# raise
clone_instance = copy(self) clone_instance = copy(self)
#delattr(self, '__call__')
#if hasattr(clone_instance, '__call__'):
# delattr(clone_instance, '__call__')
clone_instance.__name__ = id clone_instance.__name__ = id
return clone_instance return clone_instance
def asAlias(self, id):
# Returns an alias
from Alias import Alias
return Alias(id, self.__name__)
def asReindexAlias(self, id):
# Returns a reindexing alias
from Alias import ReindexAlias
return ReindexAlias(id, self.__name__)
\ No newline at end of file
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# #
############################################################################## ##############################################################################
import warnings
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
from zLOG import LOG from zLOG import LOG
...@@ -160,6 +162,9 @@ class Setter(Method): ...@@ -160,6 +162,9 @@ class Setter(Method):
portal_type=self._portal_type[0]) portal_type=self._portal_type[0])
instance._v_accessor_created_object = 1 instance._v_accessor_created_object = 1
if self._reindex: if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
o.setProperty(self._acquired_property, value, *args, **kw) o.setProperty(self._acquired_property, value, *args, **kw)
else: else:
o._setProperty(self._acquired_property, value, *args, **kw) o._setProperty(self._acquired_property, value, *args, **kw)
......
##############################################################################
#
# Copyright (c) 2007 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Accessor import Accessor as Method
# Creation of default constructor
class func_code: pass
class Reindex(Method):
"""
Calls a given accessor and reindexes the object.
TODO: reindex property may be removed on all accessors
"""
_need__name__=1
# Generic Definition of Method Object
# This is required to call the method form the Web
# More information at http://www.zope.org/Members/htrd/howto/FunctionTemplate
func_code = func_code()
func_code.co_varnames = ('self',)
func_code.co_argcount = 1
func_defaults = ()
def __init__(self, id, accessor_id):
self._id = id
self.__name__ = id
self._accessor_id = accessor_id
def __call__(self, instance, *args, **kw):
method = getattr(instance, self._accessor_id)
method(*args, **kw)
instance.reindexObject()
class Dummy(Reindex):
"""
Calls a given accessor.
"""
_need__name__=1
# Generic Definition of Method Object
# This is required to call the method form the Web
# More information at http://www.zope.org/Members/htrd/howto/FunctionTemplate
func_code = func_code()
func_code.co_varnames = ('self',)
func_code.co_argcount = 1
func_defaults = ()
def __init__(self, id, accessor_id):
self._id = id
self.__name__ = id
self._accessor_id = accessor_id
def __call__(self, instance, *args, **kw):
method = getattr(instance, self._accessor_id)
method(*args, **kw)
\ No newline at end of file
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# #
############################################################################## ##############################################################################
import warnings
from ZPublisher.HTTPRequest import FileUpload from ZPublisher.HTTPRequest import FileUpload
from TypeDefinition import type_definition, list_types, ATTRIBUTE_PREFIX from TypeDefinition import type_definition, list_types, ATTRIBUTE_PREFIX
from Accessor import Accessor as Method from Accessor import Accessor as Method
...@@ -91,6 +93,9 @@ class Setter(Method): ...@@ -91,6 +93,9 @@ class Setter(Method):
setattr(instance, self._storage_id, self._cast(args[0])) setattr(instance, self._storage_id, self._cast(args[0]))
else: else:
# Call the private setter # Call the private setter
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
method = getattr(instance, '_' + self._id) method = getattr(instance, '_' + self._id)
method(*args, **kw) method(*args, **kw)
if self._reindex: instance.reindexObject() # XXX Should the Setter check if self._reindex: instance.reindexObject() # XXX Should the Setter check
...@@ -108,13 +113,13 @@ evaluateTales = CachingMethod(_evaluateTales, id = 'evaluateTales', cache_factor ...@@ -108,13 +113,13 @@ evaluateTales = CachingMethod(_evaluateTales, id = 'evaluateTales', cache_factor
class Getter(Method): class Getter(Method):
""" """
Gets an attribute value. A default value can be provided if needed. Gets an attribute value. A default value can be provided if needed.
Note that 'default' argument is the first positional argument, this is Note that 'default' argument is the first positional argument, this is
important if you want to override a Getter in a class, overloaded important if you want to override a Getter in a class, overloaded
accessors have to respect this:: accessors have to respect this::
getSomething(self, [default], [name=value, [name=value], ]) getSomething(self, [default], [name=value, [name=value], ])
""" """
_need__name__=1 _need__name__=1
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# #
############################################################################## ##############################################################################
import warnings
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
...@@ -56,7 +58,11 @@ class ListSetter(Method): ...@@ -56,7 +58,11 @@ class ListSetter(Method):
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
base=kw.get('base', 0), base=kw.get('base', 0),
keep_default=0) keep_default=0)
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
Setter = ListSetter Setter = ListSetter
...@@ -85,7 +91,11 @@ class DefaultSetter(Method): ...@@ -85,7 +91,11 @@ class DefaultSetter(Method):
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
base=kw.get('base', 0)) base=kw.get('base', 0))
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
class SetSetter(Method): class SetSetter(Method):
""" """
...@@ -124,7 +134,11 @@ class SetSetter(Method): ...@@ -124,7 +134,11 @@ class SetSetter(Method):
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
base=kw.get('base', 0), base=kw.get('base', 0),
keep_default=1) keep_default=1)
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
class DefaultGetter(Method): class DefaultGetter(Method):
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# #
############################################################################## ##############################################################################
import warnings
from Base import func_code, type_definition, ATTRIBUTE_PREFIX, Method from Base import func_code, type_definition, ATTRIBUTE_PREFIX, Method
import Base import Base
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
...@@ -212,6 +214,9 @@ class Setter(Method): ...@@ -212,6 +214,9 @@ class Setter(Method):
if o is None: available_id = k if o is None: available_id = k
if o is not None and o.portal_type in self._portal_type: if o is not None and o.portal_type in self._portal_type:
if self._reindex: if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
o.setProperty(self._acquired_property, *args, **kw) o.setProperty(self._acquired_property, *args, **kw)
else: else:
o._setProperty(self._acquired_property, *args, **kw) o._setProperty(self._acquired_property, *args, **kw)
...@@ -222,6 +227,9 @@ class Setter(Method): ...@@ -222,6 +227,9 @@ class Setter(Method):
portal_type=self._portal_type[0]) portal_type=self._portal_type[0])
instance._v_accessor_created_object = 1 instance._v_accessor_created_object = 1
if self._reindex: if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
o.setProperty(self._acquired_property, *args, **kw) o.setProperty(self._acquired_property, *args, **kw)
else: else:
o._setProperty(self._acquired_property, *args, **kw) o._setProperty(self._acquired_property, *args, **kw)
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# #
############################################################################## ##############################################################################
import warnings
from Base import func_code, type_definition, list_types,\ from Base import func_code, type_definition, list_types,\
ATTRIBUTE_PREFIX, Method, evaluateTales ATTRIBUTE_PREFIX, Method, evaluateTales
from TypeDefinition import asList, identity from TypeDefinition import asList, identity
...@@ -90,6 +92,9 @@ class DefaultSetter(Method): ...@@ -90,6 +92,9 @@ class DefaultSetter(Method):
setattr(instance, self._storage_id, tuple(value)) setattr(instance, self._storage_id, tuple(value))
else: else:
# Call the private setter # Call the private setter
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
method = getattr(instance, '_' + self._id) method = getattr(instance, '_' + self._id)
method(*args, **kw) method(*args, **kw)
if self._reindex: instance.reindexObject() if self._reindex: instance.reindexObject()
...@@ -111,6 +116,9 @@ class ListSetter(DefaultSetter): ...@@ -111,6 +116,9 @@ class ListSetter(DefaultSetter):
setattr(instance, self._storage_id, tuple(value)) setattr(instance, self._storage_id, tuple(value))
else: else:
# Call the private setter # Call the private setter
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
method = getattr(instance, '_' + self._id) method = getattr(instance, '_' + self._id)
method(*args, **kw) method(*args, **kw)
...@@ -182,6 +190,9 @@ class SetSetter(Method): ...@@ -182,6 +190,9 @@ class SetSetter(Method):
setattr(instance, self._storage_id, tuple(new_list_value)) setattr(instance, self._storage_id, tuple(new_list_value))
else: else:
# Call the private setter # Call the private setter
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
method = getattr(instance, '_' + self._id) method = getattr(instance, '_' + self._id)
method(*args, **kw) method(*args, **kw)
if self._reindex: instance.reindexObject() if self._reindex: instance.reindexObject()
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# #
############################################################################## ##############################################################################
import warnings
from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method from Base import func_code, type_definition, list_types, ATTRIBUTE_PREFIX, Method
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
...@@ -53,7 +55,11 @@ class SetSetter(Method): ...@@ -53,7 +55,11 @@ class SetSetter(Method):
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
keep_default=1) keep_default=1)
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
psyco.bind(__call__) psyco.bind(__call__)
...@@ -71,7 +77,11 @@ class ListSetter(SetSetter): ...@@ -71,7 +77,11 @@ class ListSetter(SetSetter):
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
keep_default=0) keep_default=0)
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
psyco.bind(__call__) psyco.bind(__call__)
...@@ -90,7 +100,11 @@ class DefaultSetter(SetSetter): ...@@ -90,7 +100,11 @@ class DefaultSetter(SetSetter):
spec=kw.get('spec',()), spec=kw.get('spec',()),
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',())) portal_type=kw.get('portal_type',()))
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
psyco.bind(__call__) psyco.bind(__call__)
...@@ -447,7 +461,11 @@ class UidSetSetter(Method): ...@@ -447,7 +461,11 @@ class UidSetSetter(Method):
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
keep_default=1) keep_default=1)
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
class UidListSetter(UidSetSetter): class UidListSetter(UidSetSetter):
""" """
...@@ -463,7 +481,11 @@ class UidListSetter(UidSetSetter): ...@@ -463,7 +481,11 @@ class UidListSetter(UidSetSetter):
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
keep_default=0) keep_default=0)
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
UidSetter = UidListSetter UidSetter = UidListSetter
...@@ -480,7 +502,11 @@ class UidDefaultSetter(UidSetSetter): ...@@ -480,7 +502,11 @@ class UidDefaultSetter(UidSetSetter):
spec=kw.get('spec',()), spec=kw.get('spec',()),
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',())) portal_type=kw.get('portal_type',()))
if self._reindex: instance.reindexObject() if self._reindex:
warnings.warn("The reindexing accessors are deprecated.\n"
"Please use Alias.Reindex instead.",
DeprecationWarning)
instance.reindexObject()
class DefaultIdGetter(Method): class DefaultIdGetter(Method):
""" """
......
...@@ -1397,7 +1397,8 @@ except (ImportError, AttributeError): ...@@ -1397,7 +1397,8 @@ except (ImportError, AttributeError):
from Base import Base as BaseClass from Base import Base as BaseClass
from Accessor import Base, List, Acquired, Content,\ from Accessor import Base, List, Acquired, Content,\
AcquiredProperty, ContentProperty AcquiredProperty, ContentProperty, \
Alias
import types import types
# Compile accessors # Compile accessors
...@@ -1589,7 +1590,7 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1589,7 +1590,7 @@ def createDefaultAccessors(property_holder, id, prop = None,
reindex = 1 reindex = 1
) )
if not hasattr(property_holder, accessor_name) or prop.get('override',0): if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor) setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name ) property_holder.security.declareProtected( write_permission, accessor_name )
accessor_name = '_set' + UpperCase(composed_id) accessor_name = '_set' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0): if not hasattr(property_holder, accessor_name) or prop.get('override',0):
...@@ -1617,7 +1618,7 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1617,7 +1618,7 @@ def createDefaultAccessors(property_holder, id, prop = None,
reindex = 1 reindex = 1
) )
if not hasattr(property_holder, accessor_name) or prop.get('override',0): if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor) setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name ) property_holder.security.declareProtected( write_permission, accessor_name )
accessor_name = '_setDefault' + UpperCase(composed_id) accessor_name = '_setDefault' + UpperCase(composed_id)
if not hasattr(property_holder, accessor_name) or prop.get('override',0): if not hasattr(property_holder, accessor_name) or prop.get('override',0):
...@@ -1780,16 +1781,12 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1780,16 +1781,12 @@ def createDefaultAccessors(property_holder, id, prop = None,
setattr(property_holder, accessor_name, base_accessor) setattr(property_holder, accessor_name, base_accessor)
property_holder.security.declareProtected( write_permission, accessor_name ) property_holder.security.declareProtected( write_permission, accessor_name )
accessor_name = 'set' + UpperCase(composed_id) accessor_name = 'set' + UpperCase(composed_id)
base_accessor = ContentProperty.Setter(accessor_name, composed_id, prop['type'], aq_id,
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'), reindex=1)
if not hasattr(property_holder, accessor_name) or prop.get('override',0): if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor) setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name ) property_holder.security.declareProtected( write_permission, accessor_name )
accessor_name = 'set' + UpperCase(composed_id) + 'List' accessor_name = 'set' + UpperCase(composed_id) + 'List'
base_accessor = ContentProperty.Setter(accessor_name, composed_id + '_list', prop['type'], aq_id + '_list',
portal_type = prop.get('portal_type'), storage_id = prop.get('storage_id'), reindex=1)
if not hasattr(property_holder, accessor_name) or prop.get('override',0): if not hasattr(property_holder, accessor_name) or prop.get('override',0):
setattr(property_holder, accessor_name, base_accessor) setattr(property_holder, accessor_name, Alias.Reindex(accessor_name, '_' + accessor_name))
property_holder.security.declareProtected( write_permission, accessor_name ) property_holder.security.declareProtected( write_permission, accessor_name )
# No default getter YET XXXXXXXXXXXXXX # No default getter YET XXXXXXXXXXXXXX
# No list getter YET XXXXXXXXXXXXXX # No list getter YET XXXXXXXXXXXXXX
...@@ -1809,40 +1806,22 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1809,40 +1806,22 @@ def createDefaultAccessors(property_holder, id, prop = None,
###################################################### ######################################################
# Create Setters # Create Setters
if prop['type'] in list_types or prop.get('multivalued', 0): if prop['type'] in list_types or prop.get('multivalued', 0):
# Create setters for a list property (reindexing) # Create setters for a list property by aliasing
# The base accessor sets the list to a singleton
# and allows simulates a simple property
setter_name = 'set' + UpperCase(id)
base_setter = List.Setter(setter_name, id, prop['type'], reindex=1,
storage_id = prop.get('storage_id'))
# The default setter sets the first item of a list without changing other items
setter_name = 'setDefault' + UpperCase(id)
default_setter = List.DefaultSetter(setter_name, id, prop['type'], reindex=1,
storage_id = prop.get('storage_id'))
# The list setter sets the whole list
setter_name = 'set' + UpperCase(id) + 'List'
list_setter = List.ListSetter(setter_name, id, prop['type'], reindex=1,
storage_id = prop.get('storage_id'))
# The list setter sets the whole list
setter_name = 'set' + UpperCase(id) + 'Set'
set_setter = List.SetSetter(setter_name, id, prop['type'], reindex=1,
storage_id = prop.get('storage_id'))
# Create setters for a list property
setter_name = 'set' + UpperCase(id) setter_name = 'set' + UpperCase(id)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) setter_name = 'setDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'List' setter_name = 'set' + UpperCase(id) + 'List'
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, list_setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'Set' setter_name = 'set' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, set_setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
# Create setters for a list property (no reindexing) # Create setters for a list property (no reindexing)
# The base accessor sets the list to a singleton # The base accessor sets the list to a singleton
...@@ -1892,29 +1871,25 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1892,29 +1871,25 @@ def createDefaultAccessors(property_holder, id, prop = None,
# Create setters for a list property (reindexing) # Create setters for a list property (reindexing)
# The base accessor sets the list to a singleton # The base accessor sets the list to a singleton
# and allows simulates a simple property # and allows simulates a simple property
setter_name = 'set' + UpperCase(id) base_setter_name = 'set' + UpperCase(id)
base_setter = Content.Setter(setter_name, id, prop['type'], reindex=1,
storage_id = prop.get('storage_id'))
# The default setter sets the first item of a list without changing other items # The default setter sets the first item of a list without changing other items
setter_name = 'setDefault' + UpperCase(id) default_setter_name = 'setDefault' + UpperCase(id)
default_setter = Content.DefaultSetter(setter_name, id, prop['type'], reindex=1,
storage_id = prop.get('storage_id'))
# Create setters for an object property # Create setters for an object property
setter_name = 'set' + UpperCase(id) setter_name = 'set' + UpperCase(id)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name)) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + base_setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) setter_name = 'setDefault' + UpperCase(id)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name)) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + default_setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'Value' setter_name = 'set' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, base_setter.dummy_copy(setter_name)) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + base_setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) + 'Value' setter_name = 'setDefault' + UpperCase(id) + 'Value'
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, default_setter.dummy_copy(setter_name)) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + default_setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
# Create setters for a list property (no reindexing) # Create setters for a list property (no reindexing)
# The base accessor sets the list to a singleton # The base accessor sets the list to a singleton
...@@ -1954,10 +1929,8 @@ def createDefaultAccessors(property_holder, id, prop = None, ...@@ -1954,10 +1929,8 @@ def createDefaultAccessors(property_holder, id, prop = None,
else: else:
# Create setters for a simple property # Create setters for a simple property
setter_name = 'set' + UpperCase(id) setter_name = 'set' + UpperCase(id)
setter = Base.Setter(setter_name, id, prop['type'], reindex=1,
storage_id = prop.get('storage_id'))
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = '_set' + UpperCase(id) setter_name = '_set' + UpperCase(id)
setter = Base.Setter(setter_name, id, prop['type'], reindex=0, setter = Base.Setter(setter_name, id, prop['type'], reindex=0,
...@@ -2070,21 +2043,18 @@ def createCategoryAccessors(property_holder, id, ...@@ -2070,21 +2043,18 @@ def createCategoryAccessors(property_holder, id,
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name)) setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
setter_name = 'set' + UpperCase(id) setter_name = 'set' + UpperCase(id)
setter = Category.Setter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'List' setter_name = 'set' + UpperCase(id) + 'List'
setter = Category.ListSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) setter_name = 'setDefault' + UpperCase(id)
setter = Category.DefaultSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = '_set' + UpperCase(id) setter_name = '_set' + UpperCase(id)
...@@ -2112,7 +2082,7 @@ def createCategoryAccessors(property_holder, id, ...@@ -2112,7 +2082,7 @@ def createCategoryAccessors(property_holder, id,
setattr(property_holder, setter_name, setter.dummy_copy(setter_name)) setattr(property_holder, setter_name, setter.dummy_copy(setter_name))
setter_name = 'set' + UpperCase(id) + 'Set' setter_name = 'set' + UpperCase(id) + 'Set'
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter.dummy_copy(setter_name)) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = '_setDefault' + UpperCase(id) setter_name = '_setDefault' + UpperCase(id)
...@@ -2434,27 +2404,23 @@ def createValueAccessors(property_holder, id, ...@@ -2434,27 +2404,23 @@ def createValueAccessors(property_holder, id,
setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name)) setattr(property_holder, accessor_name, accessor.dummy_copy(accessor_name))
setter_name = 'set' + UpperCase(id) + 'Value' setter_name = 'set' + UpperCase(id) + 'Value'
setter = Value.Setter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'ValueList' setter_name = 'set' + UpperCase(id) + 'ValueList'
setter = Value.ListSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'ValueSet' setter_name = 'set' + UpperCase(id) + 'ValueSet'
setter = Value.SetSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) + 'Value' setter_name = 'setDefault' + UpperCase(id) + 'Value'
setter = Value.DefaultSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = '_set' + UpperCase(id) + 'Value' setter_name = '_set' + UpperCase(id) + 'Value'
...@@ -2499,27 +2465,23 @@ def createValueAccessors(property_holder, id, ...@@ -2499,27 +2465,23 @@ def createValueAccessors(property_holder, id,
# Uid setters # Uid setters
setter_name = 'set' + UpperCase(id) + 'Uid' setter_name = 'set' + UpperCase(id) + 'Uid'
setter = Value.UidSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'setDefault' + UpperCase(id) + 'Uid' setter_name = 'setDefault' + UpperCase(id) + 'Uid'
setter = Value.UidDefaultSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'UidList' setter_name = 'set' + UpperCase(id) + 'UidList'
setter = Value.UidListSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = 'set' + UpperCase(id) + 'UidSet' setter_name = 'set' + UpperCase(id) + 'UidSet'
setter = Value.UidSetSetter(setter_name, id, reindex=1)
if not hasattr(property_holder, setter_name): if not hasattr(property_holder, setter_name):
setattr(property_holder, setter_name, setter) setattr(property_holder, setter_name, Alias.Reindex(setter_name, '_' + setter_name))
property_holder.security.declareProtected(write_permission, setter_name) property_holder.security.declareProtected(write_permission, setter_name)
setter_name = '_set' + UpperCase(id) + 'Uid' setter_name = '_set' + UpperCase(id) + 'Uid'
......
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